#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 show_val(int val) {
  int i;
  for (i = 31; i >= 0; i--)
    printf("_");
  printf("\n");
  for (i = 31; i >= 0; i--) {
    if (val & (1 << i)) {
      printf("1");
    } else {
      printf("0");
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<show_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1f,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1146 <show_val+0x36>
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <show_val+0x12>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1f,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11ad <show_val+0x9d>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     118e <show_val+0x7e>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    119a <show_val+0x8a>
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
jmp    119f <show_val+0x8f>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1159 <show_val+0x49>
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_val>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1f,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
bt     %ebp,%ebx
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jb     1270 <show_val+0x160>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"_\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
define void @show_val(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 31, i32* %3
br label %4
4: ; preds = %9, %1
%5 = load i32, i32* %3
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7
%10 = load i32, i32* %3
%11 = add nsw i32 %10, -1
store i32 %11, i32* %3
br label %4
12: ; preds = %4
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 31, i32* %3
br label %14
14: ; preds = %28, %12
%15 = load i32, i32* %3
%16 = icmp sge i32 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = shl i32 1, %19
%21 = and i32 %18, %20
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %27
25: ; preds = %17
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, -1
store i32 %30, i32* %3
br label %14
31: ; preds = %14
%32 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
define void @show_val(i32 %0) {
%2 = tail call i32 @putchar(i32 95)
%3 = tail call i32 @putchar(i32 95)
%4 = tail call i32 @putchar(i32 95)
%5 = tail call i32 @putchar(i32 95)
%6 = tail call i32 @putchar(i32 95)
%7 = tail call i32 @putchar(i32 95)
%8 = tail call i32 @putchar(i32 95)
%9 = tail call i32 @putchar(i32 95)
%10 = tail call i32 @putchar(i32 95)
%11 = tail call i32 @putchar(i32 95)
%12 = tail call i32 @putchar(i32 95)
%13 = tail call i32 @putchar(i32 95)
%14 = tail call i32 @putchar(i32 95)
%15 = tail call i32 @putchar(i32 95)
%16 = tail call i32 @putchar(i32 95)
%17 = tail call i32 @putchar(i32 95)
%18 = tail call i32 @putchar(i32 95)
%19 = tail call i32 @putchar(i32 95)
%20 = tail call i32 @putchar(i32 95)
%21 = tail call i32 @putchar(i32 95)
%22 = tail call i32 @putchar(i32 95)
%23 = tail call i32 @putchar(i32 95)
%24 = tail call i32 @putchar(i32 95)
%25 = tail call i32 @putchar(i32 95)
%26 = tail call i32 @putchar(i32 95)
%27 = tail call i32 @putchar(i32 95)
%28 = tail call i32 @putchar(i32 95)
%29 = tail call i32 @putchar(i32 95)
%30 = tail call i32 @putchar(i32 95)
%31 = tail call i32 @putchar(i32 95)
%32 = tail call i32 @putchar(i32 95)
%33 = tail call i32 @putchar(i32 95)
%34 = tail call i32 @putchar(i32 10)
br label %35
35: ; preds = %1, %35
%36 = phi i32 [ 31, %1 ], [ %42, %35 ]
%37 = shl nuw i32 1, %36
%38 = and i32 %37, %0
%39 = icmp eq i32 %38, 0
%40 = select i1 %39, i32 48, i32 49
%41 = tail call i32 @putchar(i32 %40)
%42 = add nsw i32 %36, -1
%43 = icmp eq i32 %36, 0
br i1 %43, label %44, label %35
44: ; preds = %35
%45 = tail call i32 @putchar(i32 10)
ret void
}