#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 *, ...);
void print_bin(char *value, int value_length) {
  int i;
  char j;
  char k;
  char l;
  for (i = 0; i < value_length; i++) {
    j = value[i];
    if (j >= 32 && j < 127) {
      printf("%c", j);
    } else if (j == 9) {
      printf("\\t");
    } else if (j == 10) {
      printf("\\n");
    } else if (j == 13) {
      printf("\\r");
    } else {
      printf("\\x");
      k = ((unsigned char)j) / 16;
      l = ((unsigned char)j) % 16;
      k = (k >= 10) ? ('a' + (k - 10)) : ('0' + k);
      l = (l >= 10) ? ('a' + (l - 10)) : ('0' + l);
      printf("%c%c", k, l);
    }
  }
}


x86 assembly (clang, -O0):
<print_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1295 <print_bin+0x185>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jl     1171 <print_bin+0x61>
movsbl -0x11(%rbp),%eax
cmp    $0x7f,%eax
jge    1171 <print_bin+0x61>
movsbl -0x11(%rbp),%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1282 <print_bin+0x172>
movsbl -0x11(%rbp),%eax
cmp    $0x9,%eax
jne    1191 <print_bin+0x81>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127d <print_bin+0x16d>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    11b1 <print_bin+0xa1>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1278 <print_bin+0x168>
movsbl -0x11(%rbp),%eax
cmp    $0xd,%eax
jne    11d1 <print_bin+0xc1>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1273 <print_bin+0x163>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x11(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %al,-0x12(%rbp)
movzbl -0x11(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x13(%rbp)
movsbl -0x12(%rbp),%eax
cmp    $0xa,%eax
jl     121e <print_bin+0x10e>
movsbl -0x12(%rbp),%eax
sub    $0xa,%eax
add    $0x61,%eax
mov    %eax,-0x18(%rbp)
jmp    1228 <print_bin+0x118>
movsbl -0x12(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %al,-0x12(%rbp)
movsbl -0x13(%rbp),%eax
cmp    $0xa,%eax
jl     124d <print_bin+0x13d>
movsbl -0x13(%rbp),%eax
sub    $0xa,%eax
add    $0x61,%eax
mov    %eax,-0x1c(%rbp)
jmp    1257 <print_bin+0x147>
movsbl -0x13(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,-0x13(%rbp)
movsbl -0x12(%rbp),%esi
movsbl -0x13(%rbp),%edx
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1278 <print_bin+0x168>
jmp    127d <print_bin+0x16d>
jmp    1282 <print_bin+0x172>
jmp    1287 <print_bin+0x177>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <print_bin+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11f6 <print_bin+0xd6>
mov    %rdi,%rbx
mov    %esi,%r12d
lea    0xec3(%rip),%r15
lea    0xec5(%rip),%rbp
xor    %r13d,%r13d
jmp    1165 <print_bin+0x45>
nopl   0x0(%rax)
mov    %r14d,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
cmp    %r13,%r12
je     11f6 <print_bin+0xd6>
movzbl (%rbx,%r13,1),%r14d
lea    -0x20(%r14),%eax
cmp    $0x5e,%al
jbe    1150 <print_bin+0x30>
cmp    $0xd,%r14b
je     1192 <print_bin+0x72>
cmp    $0xa,%r14b
je     118d <print_bin+0x6d>
cmp    $0x9,%r14b
jne    11a2 <print_bin+0x82>
lea    0xe75(%rip),%rdi
jmp    1199 <print_bin+0x79>
mov    %r15,%rdi
jmp    1199 <print_bin+0x79>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1158 <print_bin+0x38>
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%eax
shr    $0x4,%al
mov    %r14d,%ecx
and    $0xf,%cl
lea    0x57(%rax),%edx
or     $0x30,%al
cmp    $0xa0,%r14b
movzbl %dl,%edx
movzbl %al,%eax
cmovae %edx,%eax
lea    0x57(%rcx),%edx
lea    0x30(%rcx),%esi
cmp    $0xa,%cl
movzbl %dl,%ecx
movzbl %sil,%edx
cmovae %ecx,%edx
movzbl %al,%esi
movzbl %dl,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1158 <print_bin+0x38>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"\\t\00"
@.str.2 = [3 x i8] c"\\n\00"
@.str.3 = [3 x i8] c"\\r\00"
@.str.4 = [3 x i8] c"\\x\00"
@.str.5 = [5 x i8] c"%c%c\00"
define void @print_bin(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %97, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %100
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
store i8 %18, i8* %6
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = icmp sge i32 %20, 32
br i1 %21, label %22, label %30
22: ; preds = %13
%23 = load i8, i8* %6
%24 = sext i8 %23 to i32
%25 = icmp slt i32 %24, 127
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %96
30: ; preds = %22, %13
%31 = load i8, i8* %6
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 9
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %95
36: ; preds = %30
%37 = load i8, i8* %6
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 10
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %94
42: ; preds = %36
%43 = load i8, i8* %6
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 13
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %93
48: ; preds = %42
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%50 = load i8, i8* %6
%51 = zext i8 %50 to i32
%52 = sdiv i32 %51, 16
%53 = trunc i32 %52 to i8
store i8 %53, i8* %7
%54 = load i8, i8* %6
%55 = zext i8 %54 to i32
%56 = srem i32 %55, 16
%57 = trunc i32 %56 to i8
store i8 %57, i8* %8
%58 = load i8, i8* %7
%59 = sext i8 %58 to i32
%60 = icmp sge i32 %59, 10
br i1 %60, label %61, label %66
61: ; preds = %48
%62 = load i8, i8* %7
%63 = sext i8 %62 to i32
%64 = sub nsw i32 %63, 10
%65 = add nsw i32 97, %64
br label %70
66: ; preds = %48
%67 = load i8, i8* %7
%68 = sext i8 %67 to i32
%69 = add nsw i32 48, %68
br label %70
70: ; preds = %66, %61
%71 = phi i32 [ %65, %61 ], [ %69, %66 ]
%72 = trunc i32 %71 to i8
store i8 %72, i8* %7
%73 = load i8, i8* %8
%74 = sext i8 %73 to i32
%75 = icmp sge i32 %74, 10
br i1 %75, label %76, label %81
76: ; preds = %70
%77 = load i8, i8* %8
%78 = sext i8 %77 to i32
%79 = sub nsw i32 %78, 10
%80 = add nsw i32 97, %79
br label %85
81: ; preds = %70
%82 = load i8, i8* %8
%83 = sext i8 %82 to i32
%84 = add nsw i32 48, %83
br label %85
85: ; preds = %81, %76
%86 = phi i32 [ %80, %76 ], [ %84, %81 ]
%87 = trunc i32 %86 to i8
store i8 %87, i8* %8
%88 = load i8, i8* %7
%89 = sext i8 %88 to i32
%90 = load i8, i8* %8
%91 = sext i8 %90 to i32
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %89, i32 %91)
br label %93
93: ; preds = %85, %46
br label %94
94: ; preds = %93, %40
br label %95
95: ; preds = %94, %34
br label %96
96: ; preds = %95, %26
br label %97
97: ; preds = %96
%98 = load i32, i32* %5
%99 = add nsw i32 %98, 1
store i32 %99, i32* %5
br label %9
100: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"\\t\00"
@.str.2 = [3 x i8] c"\\n\00"
@.str.3 = [3 x i8] c"\\r\00"
@.str.4 = [3 x i8] c"\\x\00"
@.str.5 = [5 x i8] c"%c%c\00"
define void @print_bin(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %40
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %37
%7 = phi i64 [ 0, %4 ], [ %38, %37 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = add i8 %9, -32
%11 = icmp ult i8 %10, 95
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = zext i8 %9 to i32
%14 = tail call i32 @putchar(i32 %13)
br label %37
15: ; preds = %6
switch i8 %9, label %22 [
i8 9, label %16
i8 10, label %18
i8 13, label %20
]
16: ; preds = %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %37
18: ; preds = %15
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %37
20: ; preds = %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %37
22: ; preds = %15
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%24 = lshr i8 %9, 4
%25 = and i8 %9, 15
%26 = icmp ugt i8 %9, -97
%27 = add nuw nsw i8 %24, 87
%28 = or i8 %24, 48
%29 = select i1 %26, i8 %27, i8 %28
%30 = icmp ugt i8 %25, 9
%31 = add nuw nsw i8 %25, 87
%32 = or i8 %25, 48
%33 = select i1 %30, i8 %31, i8 %32
%34 = zext i8 %29 to i32
%35 = zext i8 %33 to i32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %34, i32 %35)
br label %37
37: ; preds = %12, %18, %22, %20, %16
%38 = add nuw nsw i64 %7, 1
%39 = icmp eq i64 %38, %5
br i1 %39, label %40, label %6
40: ; preds = %37, %2
ret void
}