#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
__attribute__((no, noclone)) char *fn1(int x, int y, int z) {
  static char buf[40];
  const char *p;
  switch (x) {
  case 0:
    p = "abcd";
    break;
  case 1:
    p = "efgh";
    break;
  case 2:
    p = "ijkl";
    break;
  default:
    p = "mnopq";
    break;
  }
  if (y) {
    strcpy(buf, p);
    if (z)
      strcat(buf, "ABCDEFG");
    else
      strcat(buf, "HIJKLMN");
  } else {
    strcpy(buf, p + 1);
    if (z)
      strcat(buf, "OPQ");
    else
      strcat(buf, "RST");
  }
  return buf;
}


x86 assembly (clang, -O0):
<fn1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     1166 <fn1+0x46>
jmp    1144 <fn1+0x24>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     1176 <fn1+0x56>
jmp    1155 <fn1+0x35>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     1186 <fn1+0x66>
jmp    1196 <fn1+0x76>
lea    0xe93(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11a1 <fn1+0x81>
lea    0xe88(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11a1 <fn1+0x81>
lea    0xe7d(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11a1 <fn1+0x81>
lea    0xe72(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11f5 <fn1+0xd5>
mov    -0x18(%rbp),%rsi
lea    0x2e8a(%rip),%rdi
call   1030 <strcpy@plt>
cmpl   $0x0,-0xc(%rbp)
je     11dd <fn1+0xbd>
lea    0x2e74(%rip),%rdi
lea    0xe42(%rip),%rsi
call   1040 <strcat@plt>
jmp    11f0 <fn1+0xd0>
lea    0x2e5c(%rip),%rdi
lea    0xe32(%rip),%rsi
call   1040 <strcat@plt>
jmp    1243 <fn1+0x123>
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
lea    0x2e3c(%rip),%rdi
call   1030 <strcpy@plt>
cmpl   $0x0,-0xc(%rbp)
je     122b <fn1+0x10b>
lea    0x2e26(%rip),%rdi
lea    0xe04(%rip),%rsi
call   1040 <strcat@plt>
jmp    123e <fn1+0x11e>
lea    0x2e0e(%rip),%rdi
lea    0xdf0(%rip),%rsi
call   1040 <strcat@plt>
jmp    1243 <fn1+0x123>
lea    0x2df6(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn1>:
push   %rbx
mov    %edx,%ebx
mov    %esi,%eax
cmp    $0x2,%edi
ja     115d <fn1+0x3d>
movslq %edi,%rcx
lea    0xefc(%rip),%rdx
movslq (%rdx,%rcx,4),%rsi
add    %rdx,%rsi
test   %eax,%eax
je     1168 <fn1+0x48>
lea    0x2efa(%rip),%rdi
call   1030 <strcpy@plt>
test   %ebx,%ebx
lea    0xec9(%rip),%rax
lea    0xeba(%rip),%rsi
jmp    1188 <fn1+0x68>
lea    0xeab(%rip),%rsi
test   %eax,%eax
jne    113f <fn1+0x1f>
add    $0x1,%rsi
lea    0x2ecd(%rip),%rdi
call   1030 <strcpy@plt>
test   %ebx,%ebx
lea    0xea8(%rip),%rax
lea    0xe9d(%rip),%rsi
cmove  %rax,%rsi
lea    0x2ead(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strcat@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@fn1.buf = internal global [40 x i8] zeroinitializer
@.str = [5 x i8] c"abcd\00"
@.str.1 = [5 x i8] c"efgh\00"
@.str.2 = [5 x i8] c"ijkl\00"
@.str.3 = [6 x i8] c"mnopq\00"
@.str.4 = [8 x i8] c"ABCDEFG\00"
@.str.5 = [8 x i8] c"HIJKLMN\00"
@.str.6 = [4 x i8] c"OPQ\00"
@.str.7 = [4 x i8] c"RST\00"
define i8* @fn1(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
switch i32 %8, label %12 [
i32 0, label %9
i32 1, label %10
i32 2, label %11
]
9: ; preds = %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %7
br label %13
10: ; preds = %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %13
11: ; preds = %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %13
12: ; preds = %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %13
13: ; preds = %12, %11, %10, %9
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i8*, i8** %7
%18 = call i32 @strcpy(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* %17)
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @strcat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %25
23: ; preds = %16
%24 = call i32 @strcat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %25
25: ; preds = %23, %21
br label %37
26: ; preds = %13
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i32 @strcpy(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* %28)
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = call i32 @strcat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %36
34: ; preds = %26
%35 = call i32 @strcat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
br label %37
37: ; preds = %36, %25
ret i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@fn1.buf = internal global [40 x i8] zeroinitializer
@.str = [5 x i8] c"abcd\00"
@.str.1 = [5 x i8] c"efgh\00"
@.str.2 = [5 x i8] c"ijkl\00"
@.str.3 = [6 x i8] c"mnopq\00"
@.str.4 = [8 x i8] c"ABCDEFG\00"
@.str.5 = [8 x i8] c"HIJKLMN\00"
@.str.6 = [4 x i8] c"OPQ\00"
@.str.7 = [4 x i8] c"RST\00"
@reltable.fn1 = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.fn1 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.fn1 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.fn1 to i64)) to i32)]
define i8* @fn1(i32 %0, i32 %1, i32 %2) {
%4 = icmp ult i32 %0, 3
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = sext i32 %0 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.fn1 to i8*), i64 %7)
br label %9
9: ; preds = %3, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %3 ]
%11 = icmp eq i32 %1, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i32 @strcpy(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* %10)
%14 = icmp eq i32 %2, 0
%15 = select i1 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
br label %21
16: ; preds = %9
%17 = getelementptr inbounds i8, i8* %10, i64 1
%18 = tail call i32 @strcpy(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* %17)
%19 = icmp eq i32 %2, 0
%20 = select i1 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0)
br label %21
21: ; preds = %16, %12
%22 = phi i8* [ %15, %12 ], [ %20, %16 ]
%23 = tail call i32 @strcat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* %22)
ret i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0)
}