#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 length_fast(char *);
int length_slow(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ sleep(int);
int main(void) {
  int counter = 0;
  int c_loop = 0;
  char *Lines[] = {"x", "tt", "Test", NULL};
  char *line;
  printf("%10s %4s\n", "STRING", "LEN");
  while (15 > c_loop) {
    while (NULL != Lines[counter]) {
      line = Lines[counter];
      printf("%10s: %02d\n", line, length_fast(line));
      printf("%10s: %02d\n", line, length_slow(line));
      ++counter;
    }
    ++c_loop;
    counter = 0;
    sleep(c_loop);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2c9c(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c99(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c96(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c93(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe7d(%rip),%rsi
lea    0xe7d(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xf,%eax
cmp    -0xc(%rbp),%eax
jle    124b <main+0x10b>
jmp    11b8 <main+0x78>
movslq -0x8(%rbp),%rcx
xor    %eax,%eax
cmp    -0x30(%rbp,%rcx,8),%rax
je     122e <main+0xee>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <length_fast@plt>
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <length_slow@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b8 <main+0x78>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <sleep@plt>
jmp    11a5 <main+0x65>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xeba(%rip),%rdi
lea    0xebd(%rip),%rsi
lea    0xebd(%rip),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebx
lea    0xe8f(%rip),%r14
lea    0xea7(%rip),%r15
lea    0xe83(%rip),%r12
lea    0xe7f(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <length_fast@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <length_slow@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
call   1050 <length_fast@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
call   1040 <length_slow@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
call   1050 <length_fast@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
call   1040 <length_slow@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
call   1060 <sleep@plt>
add    $0x1,%ebx
cmp    $0x10,%ebx
jne    1190 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"x\00"
@.str.1 = [3 x i8] c"tt\00"
@.str.2 = [5 x i8] c"Test\00"
@__const.main.Lines = [4 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [10 x i8] c"%10s %4s\0A\00"
@.str.4 = [7 x i8] c"STRING\00"
@.str.5 = [4 x i8] c"LEN\00"
@.str.6 = [12 x i8] c"%10s: %02d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i8*]
%5 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%6 = bitcast [4 x i8*]* %4 to i8*
%7 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %8
8: ; preds = %33, %0
%9 = load i32, i32* %3
%10 = icmp sgt i32 15, %9
br i1 %10, label %11, label %38
11: ; preds = %8
br label %12
12: ; preds = %18, %11
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 %14
%16 = load i8*, i8** %15
%17 = icmp ne i8* null, %16
br i1 %17, label %18, label %33
18: ; preds = %12
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 %20
%22 = load i8*, i8** %21
store i8* %22, i8** %5
%23 = load i8*, i8** %5
%24 = load i8*, i8** %5
%25 = call i32 @length_fast(i8* %24)
%26 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %23, i32 %25)
%27 = load i8*, i8** %5
%28 = load i8*, i8** %5
%29 = call i32 @length_slow(i8* %28)
%30 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %27, i32 %29)
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %12
33: ; preds = %12
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
store i32 0, i32* %2
%36 = load i32, i32* %3
%37 = call i32 @sleep(i32 %36)
br label %8
38: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"x\00"
@.str.1 = [3 x i8] c"tt\00"
@.str.2 = [5 x i8] c"Test\00"
@.str.3 = [10 x i8] c"%10s %4s\0A\00"
@.str.4 = [7 x i8] c"STRING\00"
@.str.5 = [4 x i8] c"LEN\00"
@.str.6 = [12 x i8] c"%10s: %02d\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %16, %2 ]
%4 = tail call i32 @length_fast(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @length_slow(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 @length_fast(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 @length_slow(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = tail call i32 @length_fast(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = tail call i32 @length_slow(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = add nuw nsw i32 %3, 1
%17 = tail call i32 @sleep(i32 %16)
%18 = icmp eq i32 %16, 15
br i1 %18, label %19, label %2
19: ; preds = %2
ret i32 0
}