#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 */
typedef int /*<<< orphan*/ buf0;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdin;
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ system(char *);
int main() {
  char buf0[50];
  char buf1[50];
  while (1 == 1) {
    puts("Since we are falling down a bottoless pit, what do you want to do?");
    fgets(buf0, sizeof(buf0), stdin);
    if (strncmp(buf0, "0", 1) == 0) {
      fgets(buf0, sizeof(buf0), stdin);
    }
    if (strncmp(buf0, "1", 1) == 0) {
      system("/bin/ls");
    }
    if (strncmp(buf0, "2", 1) == 0) {
      printf(buf1);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1040 <puts@plt>
lea    -0x40(%rbp),%rdi
mov    0x2e6f(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1070 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11bb <main+0x6b>
lea    -0x40(%rbp),%rdi
mov    0x2e39(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1070 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11e6 <main+0x96>
lea    0xe66(%rip),%rdi
call   1050 <system@plt>
lea    -0x40(%rbp),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    120e <main+0xbe>
lea    -0x80(%rbp),%rdi
call   1060 <printf@plt>
jmp    1162 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe9b(%rip),%r14
mov    0x2e7c(%rip),%r13
lea    0x40(%rsp),%rbx
lea    0xecb(%rip),%r15
lea    0xec6(%rip),%r12
lea    0xec9(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11cf <main+0x7f>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11f0 <main+0xa0>
lea    0xe5c(%rip),%rdi
call   1050 <system@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1190 <main+0x40>
mov    %rsp,%rdi
call   1060 <printf@plt>
jmp    1190 <main+0x40>

LLVM IR (-O0):
@.str = [67 x i8] c"Since we are falling down a bottoless pit, what do you want to do?\00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [8 x i8] c"/bin/ls\00"
@.str.4 = [2 x i8] c"2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %0, %29
%5 = call i32 @puts(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 50, i32 %7)
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%10 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 50, i32 %14)
br label %16
16: ; preds = %12, %4
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%18 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%24 = call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%28 = call i32 @printf(i8* %27)
br label %29
29: ; preds = %26, %22
br label %4
}

LLVM IR (-O2):
@.str = [67 x i8] c"Since we are falling down a bottoless pit, what do you want to do?\00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [8 x i8] c"/bin/ls\00"
@.str.4 = [2 x i8] c"2\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %24, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %3, i32 50, i32 %7)
%9 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %5
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %3, i32 50, i32 %12)
br label %14
14: ; preds = %11, %5
%15 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
%20 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @printf(i8* %4)
br label %24
24: ; preds = %22, %19
br label %5
}