#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ execv(char *, char const **);
int /*<<< orphan*/ printf(char *);
char *readpw();
int /*<<< orphan*/ strcmp(char const *, char *);
int main(void) {
  const char *pw;
  printf("Password: ");
  pw = readpw();
  if (pw && !strcmp(pw, "qwin")) {
    static const char *argv[] = {"/bin/sh", 0};
    printf("\n");
    execv("/bin/sh", argv);
  } else {
    main();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <readpw@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11be <main+0x6e>
mov    -0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11be <main+0x6e>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
lea    0xe63(%rip),%rdi
lea    0x2e9c(%rip),%rsi
call   1070 <execv@plt>
jmp    11c3 <main+0x73>
call   1060 <main@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rbx
lea    0xea9(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <readpw@plt>
test   %rax,%rax
je     1170 <main+0x20>
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    1170 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe6c(%rip),%rdi
lea    0x2ea5(%rip),%rsi
call   1070 <execv@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Password: \00"
@.str.1 = [5 x i8] c"qwin\00"
@main.argv = internal global [2 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.2 = [8 x i8] c"/bin/sh\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = call i8* (...) @readpw()
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = call i32 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @main.argv, i64 0, i64 0))
br label %16
14: ; preds = %7, %0
%15 = call i32 @main()
br label %16
16: ; preds = %14, %11
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"Password: \00"
@.str.1 = [5 x i8] c"qwin\00"
@main.argv = internal global [2 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.2 = [8 x i8] c"/bin/sh\00"
define i32 @main() {
br label %1
1: ; preds = %8, %0
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* (...) @readpw()
%4 = icmp eq i8* %3, null
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %5, %1
br label %1
9: ; preds = %5
%10 = tail call i32 @putchar(i32 10)
%11 = tail call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @main.argv, i64 0, i64 0))
ret i32 0
}