#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 */
struct _ledLine {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ putChar(char, int, struct _ledLine *);
void putString(char *string, struct _ledLine *ledLine) {
  static int color = 0;
  if (!string)
    string = "null";
  while (*string) {
    if (*string == '\b')
      color = 1;
    else if (*string == '\r')
      color = 0;
    else if (*string == '\a')
      color = 2;
    else if (!putChar(*string, color, ledLine))
      return;
    string++;
  }
}


x86 assembly (clang, -O0):
<putString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1136 <putString+0x26>
lea    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    113b <putString+0x2b>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11eb <putString+0xdb>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x8,%eax
jne    1167 <putString+0x57>
movl   $0x1,0x2eca(%rip)
jmp    11da <putString+0xca>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    1186 <putString+0x76>
movl   $0x0,0x2eab(%rip)
jmp    11d5 <putString+0xc5>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7,%eax
jne    11a5 <putString+0x95>
movl   $0x2,0x2e8c(%rip)
jmp    11d0 <putString+0xc0>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    0x2e7b(%rip),%esi
mov    -0x10(%rbp),%rdx
movsbl %al,%edi
call   1030 <putChar@plt>
cmp    $0x0,%eax
jne    11cb <putString+0xbb>
jmp    11eb <putString+0xdb>
jmp    11d0 <putString+0xc0>
jmp    11d5 <putString+0xc5>
jmp    11da <putString+0xca>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113b <putString+0x2b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putString>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
test   %rdi,%rdi
lea    0xf16(%rip),%rbx
cmovne %rdi,%rbx
lea    0xed3(%rip),%r15
jmp    113c <putString+0x2c>
nop
xor    %ecx,%ecx
mov    %ecx,0x2ef4(%rip)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0xd,%rax
ja     1160 <putString+0x50>
mov    $0x1,%ecx
movslq (%r15,%rax,4),%rdx
add    %r15,%rdx
jmp    *%rdx
mov    $0x2,%ecx
jmp    1132 <putString+0x22>
nopw   0x0(%rax,%rax,1)
mov    0x2ec6(%rip),%esi
movsbl %al,%edi
mov    %r14,%rdx
call   1030 <putChar@plt>
test   %eax,%eax
jne    1138 <putString+0x28>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct._ledLine = type { i32 }
@putString.color = internal global i32 0
@.str = [5 x i8] c"null\00"
define void @putString(i8* %0, %struct._ledLine* %1) {
%3 = alloca i8*
%4 = alloca %struct._ledLine*
store i8* %0, i8** %3
store %struct._ledLine* %1, %struct._ledLine** %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
br label %8
8: ; preds = %7, %2
br label %9
9: ; preds = %42, %8
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %45
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 8
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 1, i32* @putString.color
br label %42
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 13
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 0, i32* @putString.color
br label %41
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 7
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 2, i32* @putString.color
br label %40
31: ; preds = %25
%32 = load i8*, i8** %3
%33 = load i8, i8* %32
%34 = load i32, i32* @putString.color
%35 = load %struct._ledLine*, %struct._ledLine** %4
%36 = call i32 @putChar(i8 signext %33, i32 %34, %struct._ledLine* %35)
%37 = icmp ne i32 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %31
br label %45
39: ; preds = %31
br label %40
40: ; preds = %39, %30
br label %41
41: ; preds = %40, %24
br label %42
42: ; preds = %41, %18
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %3
br label %9
45: ; preds = %38, %9
ret void
}

LLVM IR (-O2):
%struct._ledLine = type { i32 }
@putString.color = internal unnamed_addr global i32 0
@.str = [5 x i8] c"null\00"
define void @putString(i8* %0, %struct._ledLine* %1) {
%3 = icmp eq i8* %0, null
%4 = select i1 %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0
br label %5
5: ; preds = %16, %2
%6 = phi i8* [ %4, %2 ], [ %17, %16 ]
%7 = load i8, i8* %6
switch i8 %7, label %10 [
i8 0, label %18
i8 8, label %14
i8 13, label %8
i8 7, label %9
]
8: ; preds = %5
br label %14
9: ; preds = %5
br label %14
10: ; preds = %5
%11 = load i32, i32* @putString.color
%12 = tail call i32 @putChar(i8 signext %7, i32 %11, %struct._ledLine* %1)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %16
14: ; preds = %5, %9, %8
%15 = phi i32 [ 0, %8 ], [ 2, %9 ], [ 1, %5 ]
store i32 %15, i32* @putString.color
br label %16
16: ; preds = %14, %10
%17 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
18: ; preds = %5, %10
ret void
}