#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 *, char);
int str_escape_traverse(char *str) {
  char c;
  char *p = str;
  if (!p) {
    return -1;
  }
  while ((c = *p++) != '\0') {
    printf("Current character is %c\n", c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<str_escape_traverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    113b <str_escape_traverse+0x2b>
movl   $0xffffffff,-0x4(%rbp)
jmp    117c <str_escape_traverse+0x6c>
jmp    1140 <str_escape_traverse+0x30>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     1175 <str_escape_traverse+0x65>
lea    0xe99(%rip),%rdi
movsbl -0x11(%rbp),%esi
call   1030 <printf@plt>
jmp    1140 <str_escape_traverse+0x30>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_escape_traverse>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     1148 <str_escape_traverse+0x38>
mov    %rdi,%rbx
mov    (%rdi),%al
xor    %r14d,%r14d
test   %al,%al
je     114e <str_escape_traverse+0x3e>
add    $0x1,%rbx
lea    0xed0(%rip),%rbp
movsbl %al,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <str_escape_traverse+0x20>
jmp    114e <str_escape_traverse+0x3e>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Current character is %c\0A\00"
define i32 @str_escape_traverse(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 -1, i32* %2
br label %21
10: ; preds = %1
br label %11
11: ; preds = %17, %10
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %5
%14 = load i8, i8* %12
store i8 %14, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i8, i8* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8 signext %18)
br label %11
20: ; preds = %11
store i32 0, i32* %2
br label %21
21: ; preds = %20, %9
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [25 x i8] c"Current character is %c\0A\00"
define i32 @str_escape_traverse(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %3, %6
%7 = phi i8 [ %11, %6 ], [ %4, %3 ]
%8 = phi i8* [ %9, %6 ], [ %0, %3 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8 signext %7)
%11 = load i8, i8* %9
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %6
13: ; preds = %6, %3, %1
%14 = phi i32 [ -1, %1 ], [ 0, %3 ], [ 0, %6 ]
ret i32 %14
}