#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 */
char *ycf_string_new(char *, char *, int, int);
char *get_goto_ycf_trap_location_switch(int nr_of_ycf_trap_locations) {
  int i;
  char *str = "switch(ycf_trap_location){\n";
  for (i = 1; i <= nr_of_ycf_trap_locations; i++) {
    str = ycf_string_new("%s"
                         "case %d: goto ycf_yield_location_label_%d;\n",
                         str, i, i);
  }
  str = ycf_string_new("%s\n}", str, i, i);
  return str;
}


x86 assembly (clang, -O0):
<get_goto_ycf_trap_location_switch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1161 <get_goto_ycf_trap_location_switch+0x51>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xed2(%rip),%rdi
call   1030 <ycf_string_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112d <get_goto_ycf_trap_location_switch+0x1d>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xed8(%rip),%rdi
call   1030 <ycf_string_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_goto_ycf_trap_location_switch>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1163 <get_goto_ycf_trap_location_switch+0x53>
mov    %edi,%ebx
lea    0x1(%rbx),%r14d
neg    %ebx
mov    $0x1,%ebp
lea    0xed1(%rip),%rax
lea    0xee6(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rax,%rsi
mov    %ebp,%edx
mov    %ebp,%ecx
call   1030 <ycf_string_new@plt>
lea    (%rbx,%rbp,1),%ecx
add    $0x1,%ecx
mov    %ebp,%edx
add    $0x1,%edx
mov    %edx,%ebp
cmp    $0x1,%ecx
jne    1140 <get_goto_ycf_trap_location_switch+0x30>
jmp    1170 <get_goto_ycf_trap_location_switch+0x60>
lea    0xe96(%rip),%rax
mov    $0x1,%r14d
lea    0xed3(%rip),%rdi
mov    %rax,%rsi
mov    %r14d,%edx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ycf_string_new@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"switch(ycf_trap_location){\0A\00"
@.str.1 = [46 x i8] c"%scase %d: goto ycf_yield_location_label_%d;\0A\00"
@.str.2 = [5 x i8] c"%s\0A}\00"
define i8* @get_goto_ycf_trap_location_switch(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8** %4
store i32 1, i32* %3
br label %5
5: ; preds = %14, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp sle i32 %6, %7
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = load i8*, i8** %4
%11 = load i32, i32* %3
%12 = load i32, i32* %3
%13 = call i8* @ycf_string_new(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %11, i32 %12)
store i8* %13, i8** %4
br label %14
14: ; preds = %9
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %5
17: ; preds = %5
%18 = load i8*, i8** %4
%19 = load i32, i32* %3
%20 = load i32, i32* %3
%21 = call i8* @ycf_string_new(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %18, i32 %19, i32 %20)
store i8* %21, i8** %4
%22 = load i8*, i8** %4
ret i8* %22
}

LLVM IR (-O2):
@.str = [28 x i8] c"switch(ycf_trap_location){\0A\00"
@.str.1 = [46 x i8] c"%scase %d: goto ycf_yield_location_label_%d;\0A\00"
@.str.2 = [5 x i8] c"%s\0A}\00"
define i8* @get_goto_ycf_trap_location_switch(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = add nuw i32 %0, 1
br label %5
5: ; preds = %3, %5
%6 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), %3 ]
%7 = phi i32 [ %9, %5 ], [ 1, %3 ]
%8 = tail call i8* @ycf_string_new(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %6, i32 %7, i32 %7)
%9 = add nuw i32 %7, 1
%10 = icmp eq i32 %7, %0
br i1 %10, label %11, label %5
11: ; preds = %5, %1
%12 = phi i32 [ 1, %1 ], [ %4, %5 ]
%13 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), %1 ], [ %8, %5 ]
%14 = tail call i8* @ycf_string_new(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %13, i32 %12, i32 %12)
ret i8* %14
}