#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*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
long long strtoll(char *, char **, int);
int unbitify(const char *arg0, char **argv) {
  register int i, j;
  for (i = 0; argv[i]; i++) {
    char *endptr = NULL;
    long long int value = strtoll(argv[i], &endptr, 10);
    if (*endptr != '\0' || value < 0 || value > 0xffffffffLL) {
      fprintf(stderr, "%s: %s: invalid value\n", arg0, argv[i]);
      return 1;
    } else if (value == 0) {
      fputs("0\n", stdout);
    } else {
      int first = 1;
      for (j = 1; value != 0; j++) {
        if (value & 1) {
          printf(" %u" + first, j);
          first = 0;
        }
        value >>= 1;
      }
      fputs("\n", stdout);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<unbitify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     129f <unbitify+0x15f>
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtoll@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ba <unbitify+0x7a>
cmpq   $0x0,-0x30(%rbp)
jl     11ba <unbitify+0x7a>
mov    $0xffffffff,%eax
cmp    %rax,-0x30(%rbp)
jle    11eb <unbitify+0xab>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe26(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a6 <unbitify+0x166>
cmpq   $0x0,-0x30(%rbp)
jne    1210 <unbitify+0xd0>
mov    0x2ddb(%rip),%rax
mov    (%rax),%esi
lea    0xe11(%rip),%rdi
call   1040 <fputs@plt>
jmp    1287 <unbitify+0x147>
movl   $0x1,-0x34(%rbp)
movl   $0x1,-0x20(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1272 <unbitify+0x132>
mov    -0x30(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1258 <unbitify+0x118>
movslq -0x34(%rbp),%rax
lea    0xdd4(%rip),%rdi
add    %rax,%rdi
mov    -0x20(%rbp),%esi
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x30(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    121e <unbitify+0xde>
mov    0x2d5f(%rip),%rax
mov    (%rax),%esi
lea    0xd96(%rip),%rdi
call   1040 <fputs@plt>
jmp    128c <unbitify+0x14c>
jmp    1291 <unbitify+0x151>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1157 <unbitify+0x17>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unbitify>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rax
mov    (%rsi),%rdi
test   %rdi,%rdi
je     1235 <unbitify+0xf5>
mov    %rsi,%rbx
mov    %rax,0x10(%rsp)
xor    %r12d,%r12d
lea    0x8(%rsp),%r15
lea    0xea6(%rip),%r13
jmp    11a7 <unbitify+0x67>
cs nopw 0x0(%rax,%rax,1)
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
lea    0xe88(%rip),%rdi
call   1040 <fputs@plt>
mov    0x8(%rbx,%r12,8),%rdi
add    $0x1,%r12
test   %rdi,%rdi
je     1235 <unbitify+0xf5>
movq   $0x0,0x8(%rsp)
mov    %r15,%rsi
mov    $0xa,%edx
call   1050 <strtoll@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
jne    1239 <unbitify+0xf9>
test   %rbp,%rbp
js     1239 <unbitify+0xf9>
movabs $0x100000000,%rax
cmp    %rax,%rbp
jge    1239 <unbitify+0xf9>
test   %rbp,%rbp
je     1220 <unbitify+0xe0>
mov    $0x1,%eax
mov    $0x1,%r14d
jmp    1207 <unbitify+0xc7>
mov    %rbp,%rcx
sar    %rcx
add    $0x1,%r14d
cmp    $0x1,%rbp
mov    %rcx,%rbp
jbe    1180 <unbitify+0x40>
test   $0x1,%bpl
je     11f0 <unbitify+0xb0>
mov    %eax,%edi
add    %r13,%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    11f0 <unbitify+0xb0>
xchg   %ax,%ax
mov    0x2db1(%rip),%rax
mov    (%rax),%esi
lea    0xde7(%rip),%rdi
jmp    1190 <unbitify+0x50>
xor    %eax,%eax
jmp    125f <unbitify+0x11f>
mov    %r12d,%eax
mov    0x2d9d(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx,%rax,8),%rcx
lea    0xdb0(%rip),%rsi
mov    0x10(%rsp),%rdx
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"%s: %s: invalid value\0A\00"
@.str.1 = [3 x i8] c"0\0A\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c" %u\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @unbitify(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %11
11: ; preds = %75, %2
%12 = load i8**, i8*** %5
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %78
18: ; preds = %11
store i8* null, i8** %8
%19 = load i8**, i8*** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i64 @strtoll(i8* %23, i8** %8, i32 10)
store i64 %24, i64* %9
%25 = load i8*, i8** %8
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %18
%30 = load i64, i64* %9
%31 = icmp slt i64 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = load i64, i64* %9
%34 = icmp sgt i64 %33, 4294967295
br i1 %34, label %35, label %44
35: ; preds = %32, %29, %18
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %4
%38 = load i8**, i8*** %5
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %37, i8* %42)
store i32 1, i32* %3
br label %79
44: ; preds = %32
%45 = load i64, i64* %9
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i32, i32* @stdout
%49 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %48)
br label %73
50: ; preds = %44
store i32 1, i32* %10
store i32 1, i32* %7
br label %51
51: ; preds = %67, %50
%52 = load i64, i64* %9
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %70
54: ; preds = %51
%55 = load i64, i64* %9
%56 = and i64 %55, 1
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %54
%59 = load i32, i32* %10
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %60
%62 = load i32, i32* %7
%63 = call i32 @printf(i8* %61, i32 %62)
store i32 0, i32* %10
br label %64
64: ; preds = %58, %54
%65 = load i64, i64* %9
%66 = ashr i64 %65, 1
store i64 %66, i64* %9
br label %67
67: ; preds = %64
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %51
70: ; preds = %51
%71 = load i32, i32* @stdout
%72 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %70, %47
br label %74
74: ; preds = %73
br label %75
75: ; preds = %74
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %11
78: ; preds = %11
store i32 0, i32* %3
br label %79
79: ; preds = %78, %35
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"%s: %s: invalid value\0A\00"
@.str.1 = [3 x i8] c"0\0A\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c" %u\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @unbitify(i8* %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %53, label %6
6: ; preds = %2
%7 = bitcast i8** %3 to i8*
br label %8
8: ; preds = %6, %48
%9 = phi i64 [ 0, %6 ], [ %49, %48 ]
%10 = phi i8* [ %4, %6 ], [ %51, %48 ]
store i8* null, i8** %3
%11 = call i64 @strtoll(i8* %10, i8** %3, i32 10)
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
%15 = icmp slt i64 %11, 0
%16 = select i1 %14, i1 true, i1 %15
%17 = icmp sgt i64 %11, 4294967295
%18 = select i1 %16, i1 true, i1 %17
br i1 %18, label %19, label %25
19: ; preds = %8
%20 = and i64 %9, 4294967295
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %21
%24 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %23)
br label %53
25: ; preds = %8
%26 = icmp eq i64 %11, 0
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = load i32, i32* @stdout
%29 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %48
30: ; preds = %25, %40
%31 = phi i32 [ %41, %40 ], [ 1, %25 ]
%32 = phi i64 [ %42, %40 ], [ %11, %25 ]
%33 = phi i32 [ %43, %40 ], [ 1, %25 ]
%34 = and i64 %32, 1
%35 = icmp eq i64 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %30
%37 = zext i32 %31 to i64
%38 = getelementptr inbounds [4 x i8], [4 x i8]* @.str.2, i64 0, i64 %37
%39 = tail call i32 @printf(i8* %38, i32 %33)
br label %40
40: ; preds = %36, %30
%41 = phi i32 [ 0, %36 ], [ %31, %30 ]
%42 = ashr i64 %32, 1
%43 = add nuw nsw i32 %33, 1
%44 = icmp ult i64 %32, 2
br i1 %44, label %45, label %30
45: ; preds = %40
%46 = load i32, i32* @stdout
%47 = tail call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %45, %27
%49 = add nuw i64 %9, 1
%50 = getelementptr inbounds i8*, i8** %1, i64 %49
%51 = load i8*, i8** %50
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %8
53: ; preds = %48, %2, %19
%54 = phi i32 [ 1, %19 ], [ 0, %2 ], [ 0, %48 ]
ret i32 %54
}