#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
long strtol(char *, char **, int);
int bitify(const char *arg0, char **argv) {
  uint32_t value = 0;
  register int i;
  for (i = 0; argv[i]; i++) {
    char *endptr = NULL;
    long int bit = strtol(argv[i], &endptr, 10);
    if (*endptr != '\0' || bit < 0 || bit > 32) {
      fprintf(stderr, "%s: %s: invalid bit\n", arg0, argv[i]);
      return 1;
    } else if (bit != 0) {
      value |= 1 << (bit - 1);
    }
  }
  printf("%u\n", value);
  return 0;
}


x86 assembly (clang, -O0):
<bitify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1218 <bitify+0xe8>
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ad <bitify+0x7d>
cmpq   $0x0,-0x30(%rbp)
jl     11ad <bitify+0x7d>
cmpq   $0x20,-0x30(%rbp)
jle    11de <bitify+0xae>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe33(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122e <bitify+0xfe>
cmpq   $0x0,-0x30(%rbp)
je     1200 <bitify+0xd0>
mov    -0x30(%rbp),%rax
sub    $0x1,%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1205 <bitify+0xd5>
jmp    120a <bitify+0xda>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114e <bitify+0x1e>
mov    -0x1c(%rbp),%esi
lea    0xdf3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitify>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
mov    (%rsi),%rdi
xor    %r15d,%r15d
mov    $0x0,%ebp
test   %rdi,%rdi
je     11bc <bitify+0x8c>
mov    %rsi,%rbx
xor    %r13d,%r13d
lea    0x8(%rsp),%r12
xor    %r14d,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movq   $0x0,0x8(%rsp)
mov    %r12,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    11cc <bitify+0x9c>
test   %rax,%rax
js     11cc <bitify+0x9c>
cmp    $0x21,%rax
jge    11cc <bitify+0x9c>
lea    -0x1(%rax),%ecx
mov    $0x1,%edx
shl    %cl,%edx
test   %rax,%rax
cmove  %r13d,%edx
or     %edx,%ebp
mov    0x8(%rbx,%r14,8),%rdi
add    $0x1,%r14
test   %rdi,%rdi
jne    1170 <bitify+0x40>
lea    0xe52(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
jmp    11f3 <bitify+0xc3>
mov    %r14d,%eax
mov    0x2e0a(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx,%rax,8),%rcx
lea    0xe1d(%rip),%rsi
mov    0x10(%rsp),%rdx
call   1040 <fprintf@plt>
mov    $0x1,%r15d
mov    %r15d,%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 = [21 x i8] c"%s: %s: invalid bit\0A\00"
@.str.1 = [4 x i8] c"%u\0A\00"
define i32 @bitify(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
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %55, %2
%11 = load i8**, i8*** %5
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %58
17: ; preds = %10
store i8* null, i8** %8
%18 = load i8**, i8*** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i64 @strtol(i8* %22, i8** %8, i32 10)
store i64 %23, i64* %9
%24 = load i8*, i8** %8
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %34, label %28
28: ; preds = %17
%29 = load i64, i64* %9
%30 = icmp slt i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i64, i64* %9
%33 = icmp sgt i64 %32, 32
br i1 %33, label %34, label %43
34: ; preds = %31, %28, %17
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %4
%37 = load i8**, i8*** %5
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %36, i8* %41)
store i32 1, i32* %3
br label %61
43: ; preds = %31
%44 = load i64, i64* %9
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %53
46: ; preds = %43
%47 = load i64, i64* %9
%48 = sub nsw i64 %47, 1
%49 = trunc i64 %48 to i32
%50 = shl i32 1, %49
%51 = load i32, i32* %6
%52 = or i32 %51, %50
store i32 %52, i32* %6
br label %53
53: ; preds = %46, %43
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %10
58: ; preds = %10
%59 = load i32, i32* %6
%60 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %59)
store i32 0, i32* %3
br label %61
61: ; preds = %58, %34
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"%s: %s: invalid bit\0A\00"
@.str.1 = [4 x i8] c"%u\0A\00"
define i32 @bitify(i8* %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %37, label %6
6: ; preds = %2
%7 = bitcast i8** %3 to i8*
br label %8
8: ; preds = %6, %26
%9 = phi i64 [ 0, %6 ], [ %33, %26 ]
%10 = phi i8* [ %4, %6 ], [ %35, %26 ]
%11 = phi i32 [ 0, %6 ], [ %32, %26 ]
store i8* null, i8** %3
%12 = call i64 @strtol(i8* %10, i8** %3, i32 10)
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
%16 = icmp slt i64 %12, 0
%17 = select i1 %15, i1 true, i1 %16
%18 = icmp sgt i64 %12, 32
%19 = select i1 %17, i1 true, i1 %18
br i1 %19, label %20, label %26
20: ; preds = %8
%21 = and i64 %9, 4294967295
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %22
%25 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %24)
br label %40
26: ; preds = %8
%27 = icmp eq i64 %12, 0
%28 = trunc i64 %12 to i32
%29 = add nsw i32 %28, -1
%30 = shl nuw i32 1, %29
%31 = select i1 %27, i32 0, i32 %30
%32 = or i32 %31, %11
%33 = add nuw i64 %9, 1
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %8
37: ; preds = %26, %2
%38 = phi i32 [ 0, %2 ], [ %32, %26 ]
%39 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %20, %37
%41 = phi i32 [ 0, %37 ], [ 1, %20 ]
ret i32 %41
}