#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*/ not_a_prototype_v(int);
int printf(char *);
void this_one_is_correct(void) {
  int charz;
  if (printf("lol\n") == 4) {
    (void)printf("yay!\n");
  }
  not_a_prototype_v(69);
  while (printf("what\n") == 42 && 1 == 3) {
    (void)printf("this never happens...\n");
  }
  for (charz = printf("\n"); charz < printf("abc\n"); ++charz) {
    (void)printf("... but it works!\n");
  }
  charz = printf("characters?\n");
  switch (charz) {
  case 1:
    printf("one\n");
    break;
  case 2:
    (void)printf("two\n");
    break;
  }
}


x86 assembly (clang, -O0):
<this_one_is_correct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x4,%eax
jne    1149 <this_one_is_correct+0x29>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x45,%edi
call   1040 <not_a_prototype_v@plt>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2a,%ecx
mov    %al,-0x5(%rbp)
jne    1179 <this_one_is_correct+0x59>
xor    %eax,%eax
mov    %al,-0x5(%rbp)
jmp    1179 <this_one_is_correct+0x59>
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    1189 <this_one_is_correct+0x69>
jmp    119a <this_one_is_correct+0x7a>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    1153 <this_one_is_correct+0x33>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jge    11e2 <this_one_is_correct+0xc2>
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11a9 <this_one_is_correct+0x89>
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     1216 <this_one_is_correct+0xf6>
jmp    1205 <this_one_is_correct+0xe5>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     1227 <this_one_is_correct+0x107>
jmp    1233 <this_one_is_correct+0x113>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
jmp    1233 <this_one_is_correct+0x113>
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<this_one_is_correct>:
push   %r15
push   %r14
push   %rbx
lea    0xec4(%rip),%rdi
call   1040 <printf@plt>
cmp    $0x4,%eax
jne    1152 <this_one_is_correct+0x22>
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x45,%edi
call   1050 <not_a_prototype_v@plt>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
mov    %eax,%ebx
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
cmp    %eax,%ebx
jge    11b7 <this_one_is_correct+0x87>
lea    0xe97(%rip),%r14
lea    0xe71(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
add    $0x1,%ebx
mov    %r15,%rdi
call   1040 <printf@plt>
cmp    %eax,%ebx
jl     11a0 <this_one_is_correct+0x70>
lea    0xe4c(%rip),%rdi
call   1040 <printf@plt>
cmp    $0x1,%eax
je     11d6 <this_one_is_correct+0xa6>
cmp    $0x2,%eax
jne    11e7 <this_one_is_correct+0xb7>
lea    0xe48(%rip),%rdi
jmp    11dd <this_one_is_correct+0xad>
lea    0xe43(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <puts@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"lol\0A\00"
@.str.1 = [6 x i8] c"yay!\0A\00"
@.str.2 = [6 x i8] c"what\0A\00"
@.str.3 = [23 x i8] c"this never happens...\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [5 x i8] c"abc\0A\00"
@.str.6 = [19 x i8] c"... but it works!\0A\00"
@.str.7 = [13 x i8] c"characters?\0A\00"
@.str.8 = [5 x i8] c"one\0A\00"
@.str.9 = [5 x i8] c"two\0A\00"
define void @this_one_is_correct() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 4
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %4, %0
%7 = call i32 @not_a_prototype_v(i32 69)
br label %8
8: ; preds = %14, %6
%9 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %9, 42
br i1 %10, label %11, label %12
11: ; preds = %8
br label %12
12: ; preds = %11, %8
%13 = phi i1 [ false, %8 ], [ false, %11 ]
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %8
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 %17, i32* %1
br label %18
18: ; preds = %24, %16
%19 = load i32, i32* %1
%20 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %24
24: ; preds = %22
%25 = load i32, i32* %1
%26 = add nsw i32 %25, 1
store i32 %26, i32* %1
br label %18
27: ; preds = %18
%28 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
store i32 %28, i32* %1
%29 = load i32, i32* %1
switch i32 %29, label %34 [
i32 1, label %30
i32 2, label %32
]
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %34
32: ; preds = %27
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %34
34: ; preds = %27, %32, %30
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"lol\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [5 x i8] c"abc\0A\00"
@.str.7 = [13 x i8] c"characters?\0A\00"
@str = [5 x i8] c"what\00"
@str.10 = [4 x i8] c"two\00"
@str.11 = [4 x i8] c"one\00"
@str.12 = [18 x i8] c"... but it works!\00"
@str.13 = [5 x i8] c"yay!\00"
define void @this_one_is_correct() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 4
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.13, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @not_a_prototype_v(i32 69)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %5, %11
%12 = phi i32 [ %14, %11 ], [ %8, %5 ]
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0))
%14 = add nsw i32 %12, 1
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%16 = icmp slt i32 %14, %15
br i1 %16, label %11, label %17
17: ; preds = %11, %5
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
switch i32 %18, label %23 [
i32 1, label %20
i32 2, label %19
]
19: ; preds = %17
br label %20
20: ; preds = %17, %19
%21 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.10, i64 0, i64 0), %19 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.11, i64 0, i64 0), %17 ]
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
br label %23
23: ; preds = %20, %17
ret void
}