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

/* Variables and functions */
char *mpz_get_str(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set_str(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  mpz_t a;
  if (argc < 2) {
    printf("Please supply at least one binary integer.\n");
    return 1;
  }
  mpz_init_set_str(a, argv[1], 2);
  printf("%s\n", mpz_get_str(NULL, 10, a));
  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)
cmpl   $0x2,-0x8(%rbp)
jge    116a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a8 <main+0x78>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x2,%edx
call   1040 <mpz_init_set_str@plt>
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%esi
call   1050 <mpz_get_str@plt>
mov    %rax,%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jge    1144 <main+0x14>
mov    $0x1,%ebx
lea    0xebe(%rip),%rdi
jmp    1163 <main+0x33>
mov    0x8(%rsi),%rsi
mov    $0x2,%edx
call   1040 <mpz_init_set_str@plt>
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0xa,%esi
call   1050 <mpz_get_str@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Please supply at least one binary integer.\0A\00"
@.str.1 = [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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %20
11: ; preds = %2
%12 = load i32, i32* %6
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @mpz_init_set_str(i32 %12, i8* %15, i32 2)
%17 = load i32, i32* %6
%18 = call i8* @mpz_get_str(i32* null, i32 10, i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
store i32 0, i32* %3
br label %20
20: ; preds = %11, %9
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@str = [43 x i8] c"Please supply at least one binary integer.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @mpz_init_set_str(i32 undef, i8* %6, i32 2)
%8 = tail call i8* @mpz_get_str(i32* null, i32 10, i32 undef)
br label %9
9: ; preds = %2, %4
%10 = phi i8* [ %8, %4 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0), %2 ]
%11 = phi i32 [ 0, %4 ], [ 1, %2 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret i32 %11
}