#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*/ begin();
int /*<<< orphan*/ delay(int);
int /*<<< orphan*/ light_letter(int);
int /*<<< orphan*/ off();
int strlen(char *);
void loop() {
  begin();
  char phrase[] = "AB CD";
  int i;
  for (i = 0; i < strlen(phrase); i++) {
    switch (phrase[i]) {
    case 'A':
      light_letter(0);
      break;
    case 'B':
      light_letter(1);
      break;
    case 'C':
      light_letter(2);
      break;
    case 'D':
      light_letter(3);
      break;
    case ' ':
      off();
      delay(1000);
      break;
    default:
      off();
    }
  }
}


x86 assembly (clang, -O0):
<loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1070 <begin@plt>
mov    0xf2f(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xf29(%rip),%ax
mov    %ax,-0x2(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    -0x6(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    122e <loop+0xde>
movslq -0xc(%rbp),%rax
movsbl -0x6(%rbp,%rax,1),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x24,%eax
ja     1214 <loop+0xc4>
mov    -0x18(%rbp),%rax
lea    0xe44(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %edi,%edi
call   1030 <light_letter@plt>
jmp    121b <loop+0xcb>
mov    $0x1,%edi
call   1030 <light_letter@plt>
jmp    121b <loop+0xcb>
mov    $0x2,%edi
call   1030 <light_letter@plt>
jmp    121b <loop+0xcb>
mov    $0x3,%edi
call   1030 <light_letter@plt>
jmp    121b <loop+0xcb>
mov    $0x0,%al
call   1040 <off@plt>
mov    $0x3e8,%edi
call   1060 <delay@plt>
jmp    121b <loop+0xcb>
mov    $0x0,%al
call   1040 <off@plt>
jmp    1220 <loop+0xd0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117a <loop+0x2a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loop>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <begin@plt>
movw   $0x44,0xc(%rsp)
movl   $0x43204241,0x8(%rsp)
43
lea    0x8(%rsp),%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1209 <loop+0xb9>
lea    0x8(%rsp),%r14
lea    0xe73(%rip),%r15
xor    %ebx,%ebx
jmp    11b3 <loop+0x63>
xor    %eax,%eax
call   1040 <off@plt>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1209 <loop+0xb9>
movsbl 0x8(%rsp,%rbx,1),%eax
add    $0xffffffe0,%eax
cmp    $0x24,%eax
ja     1191 <loop+0x41>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
xor    %eax,%eax
call   1040 <off@plt>
mov    $0x3e8,%edi
call   1060 <delay@plt>
jmp    11a0 <loop+0x50>
xor    %edi,%edi
call   1030 <light_letter@plt>
jmp    11a0 <loop+0x50>
mov    $0x1,%edi
call   1030 <light_letter@plt>
jmp    11a0 <loop+0x50>
mov    $0x2,%edi
call   1030 <light_letter@plt>
jmp    11a0 <loop+0x50>
mov    $0x3,%edi
call   1030 <light_letter@plt>
jmp    11a0 <loop+0x50>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.loop.phrase = [6 x i8] c"AB CD\00"
define void @loop() {
%1 = alloca [6 x i8]
%2 = alloca i32
%3 = call i32 (...) @begin()
%4 = bitcast [6 x i8]* %1 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %30, %0
%6 = load i32, i32* %2
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
%9 = icmp slt i32 %6, %8
br i1 %9, label %10, label %33
10: ; preds = %5
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %27 [
i32 65, label %16
i32 66, label %18
i32 67, label %20
i32 68, label %22
i32 32, label %24
]
16: ; preds = %10
%17 = call i32 @light_letter(i32 0)
br label %29
18: ; preds = %10
%19 = call i32 @light_letter(i32 1)
br label %29
20: ; preds = %10
%21 = call i32 @light_letter(i32 2)
br label %29
22: ; preds = %10
%23 = call i32 @light_letter(i32 3)
br label %29
24: ; preds = %10
%25 = call i32 (...) @off()
%26 = call i32 @delay(i32 1000)
br label %29
27: ; preds = %10
%28 = call i32 (...) @off()
br label %29
29: ; preds = %27, %24, %22, %20, %18, %16
br label %30
30: ; preds = %29
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %5
33: ; preds = %5
ret void
}

LLVM IR (-O2):
@__const.loop.phrase = [6 x i8] c"AB CD\00"
define void @loop() {
%1 = alloca [6 x i8]
%2 = tail call i32 (...) @begin()
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = call i32 @strlen(i8* %3)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %29
6: ; preds = %0, %24
%7 = phi i64 [ %25, %24 ], [ 0, %0 ]
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %22 [
i32 65, label %11
i32 66, label %13
i32 67, label %15
i32 68, label %17
i32 32, label %19
]
11: ; preds = %6
%12 = call i32 @light_letter(i32 0)
br label %24
13: ; preds = %6
%14 = call i32 @light_letter(i32 1)
br label %24
15: ; preds = %6
%16 = call i32 @light_letter(i32 2)
br label %24
17: ; preds = %6
%18 = call i32 @light_letter(i32 3)
br label %24
19: ; preds = %6
%20 = call i32 (...) @off()
%21 = call i32 @delay(i32 1000)
br label %24
22: ; preds = %6
%23 = call i32 (...) @off()
br label %24
24: ; preds = %11, %13, %15, %17, %19, %22
%25 = add nuw nsw i64 %7, 1
%26 = call i32 @strlen(i8* %3)
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %6, label %29
29: ; preds = %24, %0
ret void
}