#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main() {
  char pass[256];
  gets(pass);
  if (0 == strcmp("foobar", pass)) {
    puts("OK");
    fprintf(stderr, "OK secret=\"%s\"\n", pass);
  } else {
    puts("KO");
    fprintf(stderr, "KO secret=\"%s\"\n", pass);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x110(%rbp),%rsi
lea    0xe94(%rip),%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11ac <main+0x6c>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xe68(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11d4 <main+0x94>
lea    0xe67(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xe4e(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <gets@plt>
lea    0xea4(%rip),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xe99(%rip),%rax
lea    0xea5(%rip),%rdi
cmove  %rax,%rdi
lea    0xe8a(%rip),%rax
lea    0xe96(%rip),%rbx
cmove  %rax,%rbx
call   1030 <puts@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"foobar\00"
@.str.1 = [3 x i8] c"OK\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"OK secret=\22%s\22\0A\00"
@.str.3 = [3 x i8] c"KO\00"
@.str.4 = [16 x i8] c"KO secret=\22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @gets(i8* %3)
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = icmp eq i64 0, %6
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %18
13: ; preds = %0
%14 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %13, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"foobar\00"
@.str.1 = [3 x i8] c"OK\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"OK secret=\22%s\22\0A\00"
@.str.3 = [3 x i8] c"KO\00"
@.str.4 = [16 x i8] c"KO secret=\22%s\22\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 @gets(i8* %2)
%4 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%7 = select i1 %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0)
%8 = call i32 @puts(i8* dereferenceable(1) %6)
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* %7, i8* %2)
ret i32 0
}