#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char buf[16];
  char cookie[5];
  strcpy(cookie, "good");
  printf("Address of buf: %p, of cookie: %p\n", buf, cookie);
  printf("\nWhat kind of cookies do you want? ");
  gets(buf);
  printf("cookie is %s\n", cookie);
  if (!strcmp(cookie, "bad"))
    printf("you win!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x25(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rsi
lea    -0x25(%rbp),%rdx
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x25(%rbp),%rsi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x25(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11c5 <main+0x85>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xeb2(%rip),%rsi
lea    0xb(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xea3(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1060 <gets@plt>
lea    0xebb(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x646162,0xb(%rsp)
jne    11b1 <main+0x71>
lea    0xeb2(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"good\00"
@.str.1 = [35 x i8] c"Address of buf: %p, of cookie: %p\0A\00"
@.str.2 = [36 x i8] c"\0AWhat kind of cookies do you want? \00"
@.str.3 = [14 x i8] c"cookie is %s\0A\00"
@.str.4 = [4 x i8] c"bad\00"
@.str.5 = [10 x i8] c"you win!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca [5 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %19
19: ; preds = %17, %0
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [5 x i8] c"good\00"
@.str.1 = [35 x i8] c"Address of buf: %p, of cookie: %p\0A\00"
@.str.2 = [36 x i8] c"\0AWhat kind of cookies do you want? \00"
@.str.3 = [14 x i8] c"cookie is %s\0A\00"
@.str.4 = [4 x i8] c"bad\00"
@str = [9 x i8] c"you win!\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %4)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @gets(i8* %3)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%10 = call i32 @bcmp(i8* dereferenceable(4) %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %12, %0
ret i32 0
}