#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 scalar_t__ ssize_t;
typedef int /*<<< orphan*/ buf_nopad;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ _print_bits(size_t, char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int sscanf(char *, char *, scalar_t__ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  if (argc != 2) {
    do {
      fprintf(stderr,
              "usage: %s <unsigned>"
              "\n",
              argv[0]);
      exit(EXIT_FAILURE);
    } while (0);
  }
  ssize_t n;
  if (sscanf(argv[1], "%zd", &n) != 1) {
    do {
      fprintf(stderr,
              "failed to parse input '%s' "
              "(need number)"
              "\n",
              argv[1]);
      exit(EXIT_FAILURE);
    } while (0);
  }
  char buf_nopad[65];
  char buf_pad[65];
  _print_bits((size_t)n, buf_nopad, sizeof(buf_nopad));
  const int rem = strlen(buf_nopad) % 8;
  if (rem <= 0) {
    printf("%s\n", buf_nopad);
  } else {
    memset(buf_pad, '0', 8 - rem);
    strcpy(&buf_pad[8 - rem], buf_nopad);
    printf("%s\n", buf_pad);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11d2 <main+0x52>
jmp    11a8 <main+0x28>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe41(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe35(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
je     1223 <main+0xa3>
jmp    11f8 <main+0x78>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe0a(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x41,%edx
call   10a0 <_print_bits@plt>
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jg     126e <main+0xee>
lea    -0x60(%rbp),%rsi
lea    0xde0(%rip),%rdi
call   1050 <printf@plt>
jmp    12bd <main+0x13d>
lea    -0xb0(%rbp),%rdi
mov    $0x8,%edx
sub    -0xb4(%rbp),%edx
mov    $0x30,%esi
call   1060 <memset@plt>
mov    $0x8,%eax
sub    -0xb4(%rbp),%eax
cltq
lea    -0xb0(%rbp),%rdi
add    %rax,%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xb0(%rbp),%rsi
lea    0xd8c(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    122d <main+0xad>
mov    0x8(%rbx),%rdi
lea    0xe75(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    1242 <main+0xc2>
lea    0x60(%rsp),%r14
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    $0x41,%edx
call   10a0 <_print_bits@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffff8,%ecx
sub    %ecx,%eax
test   %eax,%eax
jle    1211 <main+0x91>
lea    0x10(%rsp),%r14
mov    $0x8,%ebx
sub    %eax,%ebx
mov    %r14,%rdi
mov    $0x30,%esi
mov    %ebx,%edx
call   1060 <memset@plt>
lea    (%rsp,%rbx,1),%rdi
add    $0x10,%rdi
lea    0x60(%rsp),%rsi
call   1030 <strcpy@plt>
lea    0xe2c(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdc0(%rip),%rsi
jmp    1256 <main+0xd6>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdc4(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"usage: %s <unsigned>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [4 x i8] c"%zd\00"
@.str.2 = [42 x i8] c"failed to parse input '%s' (need number)\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [65 x i8]
%8 = alloca [65 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %22
12: ; preds = %2
br label %13
13: ; preds = %12
%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 ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; No predecessors!
br label %22
22: ; preds = %21, %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %6)
%27 = icmp ne i32 %26, 1
br i1 %27, label %28, label %38
28: ; preds = %22
br label %29
29: ; preds = %28
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; No predecessors!
br label %38
38: ; preds = %37, %22
%39 = load i64, i64* %6
%40 = getelementptr inbounds [65 x i8], [65 x i8]* %7, i64 0, i64 0
%41 = call i32 @_print_bits(i64 %39, i8* %40, i32 65)
%42 = getelementptr inbounds [65 x i8], [65 x i8]* %7, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
%44 = srem i32 %43, 8
store i32 %44, i32* %9
%45 = load i32, i32* %9
%46 = icmp sle i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %38
%48 = getelementptr inbounds [65 x i8], [65 x i8]* %7, i64 0, i64 0
%49 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %48)
br label %63
50: ; preds = %38
%51 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%52 = load i32, i32* %9
%53 = sub nsw i32 8, %52
%54 = call i32 @memset(i8* %51, i32 48, i32 %53)
%55 = load i32, i32* %9
%56 = sub nsw i32 8, %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 %57
%59 = getelementptr inbounds [65 x i8], [65 x i8]* %7, i64 0, i64 0
%60 = call i32 @strcpy(i8* %58, i8* %59)
%61 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%62 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %61)
br label %63
63: ; preds = %50, %47
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"usage: %s <unsigned>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [4 x i8] c"%zd\00"
@.str.2 = [42 x i8] c"failed to parse input '%s' (need number)\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca [65 x i8]
%5 = alloca [65 x i8]
%6 = icmp eq i32 %0, 2
br i1 %6, label %13, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = bitcast i64* %3 to i8*
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%18 = icmp eq i32 %17, 1
br i1 %18, label %25, label %19
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %15
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %13
%26 = getelementptr inbounds [65 x i8], [65 x i8]* %4, i64 0, i64 0
%27 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%28 = load i64, i64* %3
%29 = call i32 @_print_bits(i64 %28, i8* %26, i32 65)
%30 = call i32 @strlen(i8* %26)
%31 = srem i32 %30, 8
%32 = icmp slt i32 %31, 1
br i1 %32, label %39, label %33
33: ; preds = %25
%34 = sub nuw nsw i32 8, %31
%35 = call i32 @memset(i8* %27, i32 48, i32 %34)
%36 = zext i32 %34 to i64
%37 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 %36
%38 = call i32 @strcpy(i8* %37, i8* %26)
br label %39
39: ; preds = %25, %33
%40 = phi i8* [ %27, %33 ], [ %26, %25 ]
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %40)
ret i32 0
}