#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 leftmost_one(int);
int /*<<< orphan*/ printf(char *, int, int, int);
int strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int test_leftmost_one(int);
int main(int argc, char *argv[]) {
  int i;
  for (i = 1; i < argc; i++) {
    int x = strtoul(argv[i], NULL, 0);
    int v = leftmost_one(x);
    int t = test_leftmost_one(x);
    printf("x = 0x%.8x, val = 0x%.8x, test = 0x%.8x\n", x, v, t);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bc <main+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <leftmost_one@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <test_leftmost_one@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11a8 <main+0x68>
mov    %rsi,%r15
mov    %edi,%r12d
mov    $0x1,%ebx
lea    0xe9e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <leftmost_one@plt>
mov    %eax,%r13d
mov    %ebp,%edi
call   1030 <test_leftmost_one@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"x = 0x%.8x, val = 0x%.8x, test = 0x%.8x\0A\00"
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %10
10: ; preds = %29, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %32
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @strtoul(i8* %19, i32* null, i32 0)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = call i32 @leftmost_one(i32 %21)
store i32 %22, i32* %8
%23 = load i32, i32* %7
%24 = call i32 @test_leftmost_one(i32 %23)
store i32 %24, i32* %9
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26, i32 %27)
br label %29
29: ; preds = %14
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %10
32: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"x = 0x%.8x, val = 0x%.8x, test = 0x%.8x\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 1, %4 ], [ %14, %6 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32 @strtoul(i8* nocapture %9, i32* null, i32 0)
%11 = tail call i32 @leftmost_one(i32 %10)
%12 = tail call i32 @test_leftmost_one(i32 %10)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32 %12)
%14 = add nuw nsw i64 %7, 1
%15 = icmp eq i64 %14, %5
br i1 %15, label %16, label %6
16: ; preds = %6, %2
ret i32 0
}