#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*/ printf(char *, ...);
void displayAnswer(int functionNumber, int functionAnswer, char *firstArgument,
                   char *secondArgument, int thirdArgument,
                   char *strCharAnswer) {
  printf("\n\n\n\n\n");
  switch (functionNumber) {
  case 1:
    printf("Function that ran was 'strcmp'\n");
    printf("First argument: %s\n", firstArgument);
    printf("Second argument: %s\n", secondArgument);
    printf("Function answer was: %d\n", functionAnswer);
    break;
  case 2:
    printf("Function that ran was 'strncmp'\n");
    printf("First argument: %s\n", firstArgument);
    printf("Second argument: %s\n", secondArgument);
    printf("Third argument: %d\n", thirdArgument);
    printf("Function answer was: %d\n", functionAnswer);
    break;
  case 3:
    printf("Function that ran was 'strchr'\n");
    printf("First argument: %s\n", firstArgument);
    printf("Second argument: %s\n", secondArgument);
    printf("Function answer was: %s\n", strCharAnswer);
    break;
  default:
    break;
  }
  return;
}


x86 assembly (clang, -O0):
<displayAnswer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x1,%eax
je     1172 <displayAnswer+0x62>
jmp    1150 <displayAnswer+0x40>
mov    -0x2c(%rbp),%eax
sub    $0x2,%eax
je     11ba <displayAnswer+0xaa>
jmp    1161 <displayAnswer+0x51>
mov    -0x2c(%rbp),%eax
sub    $0x3,%eax
je     1213 <displayAnswer+0x103>
jmp    125c <displayAnswer+0x14c>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1261 <displayAnswer+0x151>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1261 <displayAnswer+0x151>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1261 <displayAnswer+0x151>
jmp    1261 <displayAnswer+0x151>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<displayAnswer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r13
mov    %r8d,%r12d
mov    %rcx,%r15
mov    %rdx,%rbp
mov    %esi,%r14d
mov    %edi,%ebx
lea    0xf2c(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x3,%ebx
je     1192 <displayAnswer+0x72>
cmp    $0x2,%ebx
je     11df <displayAnswer+0xbf>
cmp    $0x1,%ebx
jne    123d <displayAnswer+0x11d>
lea    0xf4d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8e(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe91(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    121e <displayAnswer+0xfe>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5b(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5e(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0e(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe11(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe2e(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe04(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"\0A\0A\0A\0A\0A\00"
@.str.1 = [32 x i8] c"Function that ran was 'strcmp'\0A\00"
@.str.2 = [20 x i8] c"First argument: %s\0A\00"
@.str.3 = [21 x i8] c"Second argument: %s\0A\00"
@.str.4 = [25 x i8] c"Function answer was: %d\0A\00"
@.str.5 = [33 x i8] c"Function that ran was 'strncmp'\0A\00"
@.str.6 = [20 x i8] c"Third argument: %d\0A\00"
@.str.7 = [32 x i8] c"Function that ran was 'strchr'\0A\00"
@.str.8 = [25 x i8] c"Function answer was: %s\0A\00"
define void @displayAnswer(i32 %0, i32 %1, i8* %2, i8* %3, i32 %4, i8* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
store i32 %0, i32* %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i8* %5, i8** %12
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %7
switch i32 %14, label %41 [
i32 1, label %15
i32 2, label %23
i32 3, label %33
]
15: ; preds = %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8*, i8** %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %10
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = load i32, i32* %8
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %42
23: ; preds = %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%25 = load i8*, i8** %9
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %10
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = load i32, i32* %11
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %8
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %42
33: ; preds = %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%35 = load i8*, i8** %9
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = load i8*, i8** %10
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %37)
%39 = load i8*, i8** %12
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %39)
br label %42
41: ; preds = %6
br label %42
42: ; preds = %41, %33, %23, %15
ret void
}

LLVM IR (-O2):
@.str.2 = [20 x i8] c"First argument: %s\0A\00"
@.str.3 = [21 x i8] c"Second argument: %s\0A\00"
@.str.4 = [25 x i8] c"Function answer was: %d\0A\00"
@.str.6 = [20 x i8] c"Third argument: %d\0A\00"
@.str.8 = [25 x i8] c"Function answer was: %s\0A\00"
@str = [5 x i8] c"\0A\0A\0A\0A\00"
@str.9 = [31 x i8] c"Function that ran was 'strchr'\00"
@str.10 = [32 x i8] c"Function that ran was 'strncmp'\00"
@str.11 = [31 x i8] c"Function that ran was 'strcmp'\00"
define void @displayAnswer(i32 %0, i32 %1, i8* %2, i8* %3, i32 %4, i8* %5) {
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
switch i32 %0, label %24 [
i32 1, label %8
i32 2, label %13
i32 3, label %19
]
8: ; preds = %6
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.11, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %1)
br label %24
13: ; preds = %6
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.10, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %4)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %1)
br label %24
19: ; preds = %6
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.9, i64 0, i64 0))
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %5)
br label %24
24: ; preds = %6, %19, %13, %8
ret void
}