#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*/ puts(char *);
int /*<<< orphan*/ s_gets(char *, int);
int main(void) {
  char try[40];
  puts("Who is buried in Grant's tomb?");
  s_gets(try, 40);
  while (try != "Grant") {
    puts("No, that's wrong. Try agin.");
    s_gets(try, 40);
  }
  puts("That's right!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    -0x30(%rbp),%rdi
mov    $0x28,%esi
call   1040 <s_gets@plt>
lea    -0x30(%rbp),%rax
lea    0xecb(%rip),%rcx
cmp    %rcx,%rax
je     117c <main+0x5c>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    -0x30(%rbp),%rdi
mov    $0x28,%esi
call   1040 <s_gets@plt>
jmp    1149 <main+0x29>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x28,%esi
call   1040 <s_gets@plt>
lea    0xed5(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x28,%esi
call   1040 <s_gets@plt>
jmp    1150 <main+0x30>

LLVM IR (-O0):
@.str = [31 x i8] c"Who is buried in Grant's tomb?\00"
@.str.1 = [6 x i8] c"Grant\00"
@.str.2 = [28 x i8] c"No, that's wrong. Try agin.\00"
@.str.3 = [14 x i8] c"That's right!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [40 x i8]
store i32 0, i32* %1
%3 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%5 = call i32 @s_gets(i8* %4, i32 40)
br label %6
6: ; preds = %9, %0
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%8 = icmp ne i8* %7, getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%12 = call i32 @s_gets(i8* %11, i32 40)
br label %6
13: ; preds = %6
%14 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Who is buried in Grant's tomb?\00"
@.str.2 = [28 x i8] c"No, that's wrong. Try agin.\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @s_gets(i8* %2, i32 40)
br label %5
5: ; preds = %5, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @s_gets(i8* %2, i32 40)
br label %5
}