#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";
    asm volatile("" : : : "memory");
    break;
  case 1:
    p = "efgh";
    break;
  case 2:
    p = "ijkl";
    break;
  default:
    p = "mnop";
    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    0xe41(%rip),%rsi
call   1040 <strcat@plt>
jmp    11f0 <fn1+0xd0>
lea    0x2e5c(%rip),%rdi
lea    0xe31(%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    0xe03(%rip),%rsi
call   1040 <strcat@plt>
jmp    123e <fn1+0x11e>
lea    0x2e0e(%rip),%rdi
lea    0xdef(%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
cmp    $0x2,%edi
je     113e <fn1+0x1e>
cmp    $0x1,%edi
je     114b <fn1+0x2b>
test   %edi,%edi
jne    1177 <fn1+0x57>
lea    0xec8(%rip),%rax
test   %esi,%esi
jne    1156 <fn1+0x36>
jmp    1182 <fn1+0x62>
lea    0xec5(%rip),%rax
test   %esi,%esi
jne    1156 <fn1+0x36>
jmp    1182 <fn1+0x62>
lea    0xeb3(%rip),%rax
test   %esi,%esi
je     1182 <fn1+0x62>
lea    0x2ee3(%rip),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
test   %ebx,%ebx
lea    0xeae(%rip),%rax
lea    0xe9f(%rip),%rsi
jmp    11a5 <fn1+0x85>
lea    0xe91(%rip),%rax
test   %esi,%esi
jne    1156 <fn1+0x36>
add    $0x1,%rax
lea    0x2eb3(%rip),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
test   %ebx,%ebx
lea    0xe8a(%rip),%rax
lea    0xe7f(%rip),%rsi
cmove  %rax,%rsi
lea    0x2e90(%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 = [5 x i8] c"mnop\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 ([5 x i8], [5 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 = [5 x i8] c"mnop\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) {
switch i32 %0, label %6 [
i32 0, label %4
i32 1, label %7
i32 2, label %5
]
4: ; preds = %3
tail call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"()
br label %7
5: ; preds = %3
br label %7
6: ; preds = %3
br label %7
7: ; preds = %3, %6, %5, %4
%8 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %3 ]
%9 = icmp eq i32 %1, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i32 @strcpy(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* %8)
%12 = icmp eq i32 %2, 0
%13 = select i1 %12, 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 %19
14: ; preds = %7
%15 = getelementptr inbounds i8, i8* %8, i64 1
%16 = tail call i32 @strcpy(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* %15)
%17 = icmp eq i32 %2, 0
%18 = select i1 %17, 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 %19
19: ; preds = %14, %10
%20 = phi i8* [ %13, %10 ], [ %18, %14 ]
%21 = tail call i32 @strcat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0), i8* %20)
ret i8* getelementptr inbounds ([40 x i8], [40 x i8]* @fn1.buf, i64 0, i64 0)
}