#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 gen(char actions[][100], int count) {
  char l1 = 'S', l2 = 'A', l3 = 'B';
  printf("\nif %s GOTO %c", actions[0], l1);
  printf("\nGOTO %c", l2);
  printf("\n%c : %s", l1, actions[1]);
  if (count < 3) {
    printf("\n%c : STOP\n", l2);
  } else {
    printf("\nGOTO %c", l3);
    printf("\n%c : %s", l2, actions[2]);
    printf("\n%c : STOP\n", l3);
  }
}


x86 assembly (clang, -O0):
<gen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movb   $0x53,-0xd(%rbp)
movb   $0x41,-0xe(%rbp)
movb   $0x42,-0xf(%rbp)
mov    -0x8(%rbp),%rsi
movsbl -0xd(%rbp),%edx
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xe(%rbp),%esi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xd(%rbp),%esi
mov    -0x8(%rbp),%rdx
add    $0x64,%rdx
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0xc(%rbp)
jge    118e <gen+0x7e>
movsbl -0xe(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cf <gen+0xbf>
movsbl -0xf(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xe(%rbp),%esi
mov    -0x8(%rbp),%rdx
add    $0xc8,%rdx
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xf(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xedf(%rip),%rdi
mov    %rbx,%rsi
mov    $0x53,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
mov    $0x41,%ebp
mov    $0x41,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x64(%rbx),%rdx
lea    0xec5(%rip),%rdi
mov    $0x53,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x3,%r14d
jl     119a <gen+0x8a>
lea    0xea3(%rip),%rdi
mov    $0x42,%ebp
mov    $0x42,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0xc8,%rbx
lea    0xe8d(%rip),%rdi
mov    $0x41,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"\0Aif %s GOTO %c\00"
@.str.1 = [9 x i8] c"\0AGOTO %c\00"
@.str.2 = [9 x i8] c"\0A%c : %s\00"
@.str.3 = [12 x i8] c"\0A%c : STOP\0A\00"
define void @gen([100 x i8]* %0, i32 %1) {
%3 = alloca [100 x i8]*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
store [100 x i8]* %0, [100 x i8]** %3
store i32 %1, i32* %4
store i8 83, i8* %5
store i8 65, i8* %6
store i8 66, i8* %7
%8 = load [100 x i8]*, [100 x i8]** %3
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %12)
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = load [100 x i8]*, [100 x i8]** %3
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %19, i64 1
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %20, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %18, i8* %21)
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 3
br i1 %24, label %25, label %29
25: ; preds = %2
%26 = load i8, i8* %6
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %42
29: ; preds = %2
%30 = load i8, i8* %7
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i8, i8* %6
%34 = sext i8 %33 to i32
%35 = load [100 x i8]*, [100 x i8]** %3
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %35, i64 2
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %36, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %34, i8* %37)
%39 = load i8, i8* %7
%40 = sext i8 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %29, %25
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"\0Aif %s GOTO %c\00"
@.str.1 = [9 x i8] c"\0AGOTO %c\00"
@.str.2 = [9 x i8] c"\0A%c : %s\00"
@.str.3 = [12 x i8] c"\0A%c : STOP\0A\00"
define void @gen([100 x i8]* %0, i32 %1) {
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 0, i64 0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %3, i32 83)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 65)
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 1, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 83, i8* %6)
%8 = icmp slt i32 %1, 3
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 66)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 2, i64 0
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 65, i8* %11)
br label %13
13: ; preds = %2, %9
%14 = phi i32 [ 66, %9 ], [ 65, %2 ]
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %14)
ret void
}