#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
scalar_t__ putc(int, int /*<<< orphan*/ *);
int print_name(FILE *fp, const char *name) {
  const char *p;
  int c;
  for (p = name; (c = (unsigned char)*p) != 0; p++) {
    if (c <= ' ' || c == '\\') {
      fprintf(fp, "\\%03o", c);
      if (ferror(fp))
        return 0;
    } else {
      if (putc(c, fp) == EOF)
        return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<print_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     11e9 <print_name+0xb9>
cmpl   $0x20,-0x24(%rbp)
jle    116f <print_name+0x3f>
cmpl   $0x5c,-0x24(%rbp)
jne    11a6 <print_name+0x76>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe83(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     11a1 <print_name+0x71>
movl   $0x0,-0x4(%rbp)
jmp    11f0 <print_name+0xc0>
jmp    11d3 <print_name+0xa3>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <putc@plt>
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%rax
jne    11ce <print_name+0x9e>
movl   $0x0,-0x4(%rbp)
jmp    11f0 <print_name+0xc0>
jmp    11d3 <print_name+0xa3>
jmp    11d8 <print_name+0xa8>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1148 <print_name+0x18>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_name>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rsi),%al
mov    $0x1,%r14d
test   %al,%al
je     11a2 <print_name+0x72>
mov    %rsi,%rbx
mov    %rdi,%rbp
add    $0x1,%rbx
lea    0xeab(%rip),%r15
mov    0x2e8c(%rip),%r12
jmp    1183 <print_name+0x53>
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r15,%rsi
call   1050 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    119f <print_name+0x6f>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11a2 <print_name+0x72>
movzbl %al,%edx
cmp    $0x21,%dl
jb     1160 <print_name+0x30>
cmp    $0x5c,%al
je     1160 <print_name+0x30>
mov    %edx,%edi
mov    %rbp,%rsi
call   1040 <putc@plt>
cmp    (%r12),%rax
jne    1178 <print_name+0x48>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"\\%03o\00"
@EOF = global i64 0
define i32 @print_name(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
store i8* %8, i8** %6
br label %9
9: ; preds = %38, %2
%10 = load i8*, i8** %6
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
store i32 %12, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %41
14: ; preds = %9
%15 = load i32, i32* %7
%16 = icmp sle i32 %15, 32
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 92
br i1 %19, label %20, label %29
20: ; preds = %17, %14
%21 = load i32*, i32** %4
%22 = load i32, i32* %7
%23 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32*, i32** %4
%25 = call i64 @ferror(i32* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %20
store i32 0, i32* %3
br label %42
28: ; preds = %20
br label %37
29: ; preds = %17
%30 = load i32, i32* %7
%31 = load i32*, i32** %4
%32 = call i64 @putc(i32 %30, i32* %31)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %29
store i32 0, i32* %3
br label %42
36: ; preds = %29
br label %37
37: ; preds = %36, %28
br label %38
38: ; preds = %37
%39 = load i8*, i8** %6
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %6
br label %9
41: ; preds = %9
store i32 1, i32* %3
br label %42
42: ; preds = %41, %35, %27
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [6 x i8] c"\\%03o\00"
@EOF = global i64 0
define i32 @print_name(i32* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %24, label %5
5: ; preds = %2, %20
%6 = phi i8 [ %22, %20 ], [ %3, %2 ]
%7 = phi i8* [ %21, %20 ], [ %1, %2 ]
%8 = zext i8 %6 to i32
%9 = icmp ult i8 %6, 33
%10 = icmp eq i8 %6, 92
%11 = or i1 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %5
%13 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %8)
%14 = tail call i64 @ferror(i32* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %24
16: ; preds = %5
%17 = tail call i64 @putc(i32 %8, i32* %0)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %24, label %20
20: ; preds = %12, %16
%21 = getelementptr inbounds i8, i8* %7, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %5
24: ; preds = %12, %16, %20, %2
%25 = phi i32 [ 1, %2 ], [ 1, %20 ], [ 0, %16 ], [ 0, %12 ]
ret i32 %25
}