#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*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ stdout;
void print(char *s) {
  while (*s) {
    if (*s >= 0x20) {
      fputc(*s, stdout);
    } else {
      printf("<%d>", *s);
    }
    ++s;
  }
  fputc('\n', stdout);
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1189 <print+0x69>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jl     1165 <print+0x45>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    0x2e8a(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
jmp    1178 <print+0x58>
mov    -0x8(%rbp),%rax
lea    0xe90(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <print+0xc>
mov    0x2e50(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1040 <fputc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1177 <print+0x57>
mov    %rdi,%rbx
add    $0x1,%rbx
mov    0x2ea7(%rip),%r15
lea    0xec0(%rip),%r14
jmp    1166 <print+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1177 <print+0x57>
cmp    $0x20,%al
jl     1150 <print+0x30>
mov    (%r15),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
jmp    115b <print+0x3b>
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fputc@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [5 x i8] c"<%d>\00"
define void @print(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %21, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = icmp ne i8 %5, 0
br i1 %6, label %7, label %24
7: ; preds = %3
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp sge i32 %10, 32
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = load i32, i32* @stdout
%16 = call i32 @fputc(i8 signext %14, i32 %15)
br label %21
17: ; preds = %7
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %19)
br label %21
21: ; preds = %17, %12
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %2
br label %3
24: ; preds = %3
%25 = load i32, i32* @stdout
%26 = call i32 @fputc(i8 signext 10, i32 %25)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [5 x i8] c"<%d>\00"
define void @print(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1, %13
%5 = phi i8 [ %15, %13 ], [ %2, %1 ]
%6 = phi i8* [ %14, %13 ], [ %0, %1 ]
%7 = icmp sgt i8 %5, 31
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = load i32, i32* @stdout
%10 = tail call i32 @fputc(i8 signext %5, i32 %9)
br label %13
11: ; preds = %4
%12 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %5)
br label %13
13: ; preds = %11, %8
%14 = getelementptr inbounds i8, i8* %6, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %13, %1
%18 = load i32, i32* @stdout
%19 = tail call i32 @fputc(i8 signext 10, i32 %18)
ret void
}