#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 *, ...);
int strlen(char *);
void runCode(char *code) {
  int c_len = strlen(code);
  int i, accumulator, bottles;
  for (i = 0; i < c_len; i++) {
    switch (code[i]) {
    case 'Q':
      printf("%s\n", code);
      break;
    case 'H':
      printf("Hello, world!\n");
      break;
    case '9':
      bottles = 99;
      do {
        printf("%d bottles of beer on the wall\n", bottles);
        printf("%d bottles of beer\n", bottles);
        printf("Take one down, pass it around\n");
        printf("%d bottles of beer on the wall\n\n", --bottles);
      } while (bottles > 0);
      break;
    case '+':
      accumulator++;
      break;
    }
  }
}


x86 assembly (clang, -O0):
<runCode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1220 <runCode+0x100>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffd5,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x26,%eax
ja     120d <runCode+0xed>
mov    -0x20(%rbp),%rax
lea    0xe8c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rsi
lea    0xf14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120d <runCode+0xed>
lea    0xf05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120d <runCode+0xed>
movl   $0x63,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xf06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
add    $0xffffffff,%esi
mov    %esi,-0x18(%rbp)
lea    0xf14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
jg     11ae <runCode+0x8e>
jmp    120d <runCode+0xed>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1212 <runCode+0xf2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <runCode+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runCode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x8(%rsp)
call   1040 <strlen@plt>
test   %eax,%eax
jle    1201 <runCode+0xd1>
mov    %eax,%eax
mov    %rax,(%rsp)
lea    0xea3(%rip),%rbx
lea    0xebc(%rip),%r14
lea    0xeea(%rip),%r12
lea    0xec2(%rip),%r15
xor    %eax,%eax
jmp    119b <runCode+0x6b>
cs nopw 0x0(%rax,%rax,1)
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%rax
add    $0x1,%rax
cmp    (%rsp),%rax
je     1201 <runCode+0xd1>
mov    0x8(%rsp),%rdi
mov    %rax,0x10(%rsp)
movsbl (%rdi,%rax,1),%eax
cmp    $0x51,%eax
je     1187 <runCode+0x57>
cmp    $0x48,%eax
je     1180 <runCode+0x50>
cmp    $0x39,%eax
jne    118c <runCode+0x5c>
mov    $0x63,%ebp
nopl   (%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r14,%r13
lea    -0x1(%rbp),%r14d
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1,%ebp
mov    %r14d,%ebp
mov    %r13,%r14
ja     11c0 <runCode+0x90>
jmp    118c <runCode+0x5c>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [15 x i8] c"Hello, world!\0A\00"
@.str.2 = [32 x i8] c"%d bottles of beer on the wall\0A\00"
@.str.3 = [20 x i8] c"%d bottles of beer\0A\00"
@.str.4 = [31 x i8] c"Take one down, pass it around\0A\00"
@.str.5 = [33 x i8] c"%d bottles of beer on the wall\0A\0A\00"
define void @runCode(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %3
store i32 0, i32* %4
br label %9
9: ; preds = %43, %1
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %46
13: ; preds = %9
%14 = load i8*, i8** %2
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
switch i32 %19, label %42 [
i32 81, label %20
i32 72, label %23
i32 57, label %25
i32 43, label %39
]
20: ; preds = %13
%21 = load i8*, i8** %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %42
23: ; preds = %13
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %42
25: ; preds = %13
store i32 99, i32* %6
br label %26
26: ; preds = %35, %25
%27 = load i32, i32* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* %6
%33 = add nsw i32 %32, -1
store i32 %33, i32* %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %26
%36 = load i32, i32* %6
%37 = icmp sgt i32 %36, 0
br i1 %37, label %26, label %38
38: ; preds = %35
br label %42
39: ; preds = %13
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %42
42: ; preds = %13, %39, %38, %23, %20
br label %43
43: ; preds = %42
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %4
br label %9
46: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str.2 = [32 x i8] c"%d bottles of beer on the wall\0A\00"
@.str.3 = [20 x i8] c"%d bottles of beer\0A\00"
@.str.5 = [33 x i8] c"%d bottles of beer on the wall\0A\0A\00"
@str = [30 x i8] c"Take one down, pass it around\00"
@str.6 = [14 x i8] c"Hello, world!\00"
define void @runCode(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %26
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %23
%7 = phi i64 [ 0, %4 ], [ %24, %23 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %23 [
i32 81, label %20
i32 72, label %11
i32 57, label %12
]
11: ; preds = %6
br label %20
12: ; preds = %6, %12
%13 = phi i32 [ %17, %12 ], [ 99, %6 ]
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%17 = add nsw i32 %13, -1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %17)
%19 = icmp ugt i32 %13, 1
br i1 %19, label %12, label %23
20: ; preds = %6, %11
%21 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0), %11 ], [ %0, %6 ]
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
br label %23
23: ; preds = %12, %20, %6
%24 = add nuw nsw i64 %7, 1
%25 = icmp eq i64 %24, %5
br i1 %25, label %26, label %6
26: ; preds = %23, %1
ret void
}