#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*/ val;

/* Variables and functions */
int CHAR_BIT;
scalar_t__ ERANGE;
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <(signed) integer>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  errno = 0;
  int val = strtol(argv[1], NULL, 10);
  if ((errno == ERANGE) || (errno != 0 && val == 0)) {
    perror("strtol()");
    exit(EXIT_FAILURE);
  }
  int size = sizeof(val);
  int bit_val = size * CHAR_BIT;
  int mask = 1 << (bit_val - 1);
  printf("%d byte - %d bit\n", size, bit_val);
  for (int i = 1; i <= bit_val; ++i) {
    (val & mask) == 0 ? printf("0") : printf("1");
    val <<= 1;
    if ((i % 8 == 0) && (i != 0))
      printf(" ");
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119a <main+0x4a>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2e27(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e00(%rip),%rax
mov    (%rax),%rax
mov    0x2e16(%rip),%rcx
cmp    (%rcx),%rax
je     11f6 <main+0xa6>
mov    0x2de6(%rip),%rax
cmpq   $0x0,(%rax)
je     1210 <main+0xc0>
cmpl   $0x0,-0x14(%rbp)
jne    1210 <main+0xc0>
lea    0xe21(%rip),%rdi
call   1060 <perror@plt>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movl   $0x4,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2db7(%rip),%rcx
imul   (%rcx),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     12d6 <main+0x186>
mov    -0x14(%rbp),%eax
and    -0x20(%rbp),%eax
cmp    $0x0,%eax
jne    1280 <main+0x130>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128e <main+0x13e>
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12c3 <main+0x173>
cmpl   $0x0,-0x24(%rbp)
je     12c3 <main+0x173>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c8 <main+0x178>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1252 <main+0x102>
mov    0x2cdb(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x1,%edi
jle    125b <main+0xfb>
mov    0x2e50(%rip),%rbx
movq   $0x0,(%rbx)
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%ebp
mov    (%rbx),%rax
mov    0x2e4d(%rip),%rcx
cmp    (%rcx),%rax
je     124d <main+0xed>
test   %rax,%rax
je     11b1 <main+0x51>
test   %ebp,%ebp
je     124d <main+0xed>
mov    0x2e20(%rip),%rax
mov    (%rax),%r12d
lea    0x0(,%r12,4),%r14d
lea    -0x1(%r14),%ecx
mov    $0x1,%ebx
mov    $0x1,%r15d
shl    %cl,%r15d
lea    0xe4b(%rip),%rdi
mov    $0x4,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12d,%r12d
jle    123b <main+0xdb>
cmp    $0x2,%r14d
cmovl  %ebx,%r14d
neg    %r14d
jmp    1215 <main+0xb5>
nopl   (%rax)
add    %ebp,%ebp
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     123b <main+0xdb>
mov    %ebp,%eax
and    %r15d,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
test   $0x7,%bl
jne    1200 <main+0xa0>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1200 <main+0xa0>
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdca(%rip),%rdi
call   1070 <perror@plt>
jmp    1273 <main+0x113>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xd92(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s <(signed) integer>\0A\00"
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@ERANGE = global i64 0
@.str.1 = [9 x i8] c"strtol()\00"
@CHAR_BIT = global i32 0
@.str.2 = [18 x i8] c"%d byte - %d bit\0A\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [2 x i8] c" \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %21
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
store i64 0, i64* @errno
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strtol(i8* %24, i32* null, i32 10)
store i32 %25, i32* %6
%26 = load i64, i64* @errno
%27 = load i64, i64* @ERANGE
%28 = icmp eq i64 %26, %27
br i1 %28, label %35, label %29
29: ; preds = %21
%30 = load i64, i64* @errno
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %32, %21
%36 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %32, %29
store i32 4, i32* %7
%40 = load i32, i32* %7
%41 = load i32, i32* @CHAR_BIT
%42 = mul nsw i32 %40, %41
store i32 %42, i32* %8
%43 = load i32, i32* %8
%44 = sub nsw i32 %43, 1
%45 = shl i32 1, %44
store i32 %45, i32* %9
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %46, i32 %47)
store i32 1, i32* %10
br label %49
49: ; preds = %75, %39
%50 = load i32, i32* %10
%51 = load i32, i32* %8
%52 = icmp sle i32 %50, %51
br i1 %52, label %53, label %78
53: ; preds = %49
%54 = load i32, i32* %6
%55 = load i32, i32* %9
%56 = and i32 %54, %55
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %62
60: ; preds = %53
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %58
%63 = phi i32 [ %59, %58 ], [ %61, %60 ]
%64 = load i32, i32* %6
%65 = shl i32 %64, 1
store i32 %65, i32* %6
%66 = load i32, i32* %10
%67 = srem i32 %66, 8
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %74
69: ; preds = %62
%70 = load i32, i32* %10
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %74
74: ; preds = %72, %69, %62
br label %75
75: ; preds = %74
%76 = load i32, i32* %10
%77 = add nsw i32 %76, 1
store i32 %77, i32* %10
br label %49
78: ; preds = %49
%79 = load i32, i32* @EXIT_SUCCESS
ret i32 %79
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s <(signed) integer>\0A\00"
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@ERANGE = global i64 0
@.str.1 = [9 x i8] c"strtol()\00"
@CHAR_BIT = global i32 0
@.str.2 = [18 x i8] c"%d byte - %d bit\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
store i64 0, i64* @errno
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @strtol(i8* nocapture %12, i32* null, i32 10)
%14 = load i64, i64* @errno
%15 = load i64, i64* @ERANGE
%16 = icmp eq i64 %14, %15
br i1 %16, label %21, label %17
17: ; preds = %10
%18 = icmp ne i64 %14, 0
%19 = icmp eq i32 %13, 0
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %21, label %25
21: ; preds = %17, %10
%22 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %17
%26 = load i32, i32* @CHAR_BIT
%27 = shl nsw i32 %26, 2
%28 = add nsw i32 %27, -1
%29 = shl nuw i32 1, %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 %27)
%31 = icmp slt i32 %26, 1
br i1 %31, label %34, label %32
32: ; preds = %25
%33 = call i32 @llvm.smax.i32(i32 %27, i32 1)
br label %36
34: ; preds = %48, %25
%35 = load i32, i32* @EXIT_SUCCESS
ret i32 %35
36: ; preds = %32, %48
%37 = phi i32 [ %49, %48 ], [ 1, %32 ]
%38 = phi i32 [ %43, %48 ], [ %13, %32 ]
%39 = and i32 %38, %29
%40 = icmp eq i32 %39, 0
%41 = select i1 %40, i32 48, i32 49
%42 = tail call i32 @putchar(i32 %41)
%43 = shl i32 %38, 1
%44 = and i32 %37, 7
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %36
%47 = tail call i32 @putchar(i32 32)
br label %48
48: ; preds = %36, %46
%49 = add nuw nsw i32 %37, 1
%50 = icmp eq i32 %37, %33
br i1 %50, label %34, label %36
}