#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 */
scalar_t__ getbits(unsigned int, int, int);
char *timlib_integer2binary(unsigned integer) {
  static char binary[32 + 1] = {0};
  char *pointer;
  int i;
  pointer = binary;
  for (i = 0; i < 32; i++, pointer++)
    *pointer = '0';
  pointer = binary + 32 - 1;
  for (i = 0; i < 32; i++, pointer--) {
    if (getbits(integer, i, 1))
      *pointer = '1';
  }
  return binary;
}


x86 assembly (clang, -O0):
<timlib_integer2binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0x2f1e(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    1158 <timlib_integer2binary+0x48>
mov    -0x10(%rbp),%rax
movb   $0x30,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112d <timlib_integer2binary+0x1d>
lea    0x2ee1(%rip),%rax
add    $0x1f,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    11b8 <timlib_integer2binary+0xa8>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x1,%edx
call   1030 <getbits@plt>
cmp    $0x0,%rax
je     1199 <timlib_integer2binary+0x89>
mov    -0x10(%rbp),%rax
movb   $0x31,(%rax)
jmp    119e <timlib_integer2binary+0x8e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    116e <timlib_integer2binary+0x5e>
lea    0x2e81(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timlib_integer2binary>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
movaps 0xee2(%rip),%xmm0
movaps %xmm0,0x2f2b(%rip)
movaps %xmm0,0x2f14(%rip)
lea    0x2f2c(%rip),%rbx
xor    %ebp,%ebp
jmp    114c <timlib_integer2binary+0x3c>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0xffffffffffffffff,%rbx
cmp    $0x20,%ebp
je     1165 <timlib_integer2binary+0x55>
mov    %r14d,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1030 <getbits@plt>
test   %rax,%rax
je     1140 <timlib_integer2binary+0x30>
movb   $0x31,(%rbx)
jmp    1140 <timlib_integer2binary+0x30>
lea    0x2ed4(%rip),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@timlib_integer2binary.binary = internal global [33 x i8] zeroinitializer
define i8* @timlib_integer2binary(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 %0, i32* %2
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @timlib_integer2binary.binary, i64 0, i64 0), i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %10, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 32
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i8*, i8** %3
store i8 48, i8* %9
br label %10
10: ; preds = %8
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %3
br label %5
15: ; preds = %5
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @timlib_integer2binary.binary, i64 0, i64 31), i8** %3
store i32 0, i32* %4
br label %16
16: ; preds = %27, %15
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 32
br i1 %18, label %19, label %32
19: ; preds = %16
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = call i64 @getbits(i32 %20, i32 %21, i32 1)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = load i8*, i8** %3
store i8 49, i8* %25
br label %26
26: ; preds = %24, %19
br label %27
27: ; preds = %26
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 -1
store i8* %31, i8** %3
br label %16
32: ; preds = %16
ret i8* getelementptr inbounds ([33 x i8], [33 x i8]* @timlib_integer2binary.binary, i64 0, i64 0)
}

LLVM IR (-O2):
@timlib_integer2binary.binary = internal global [33 x i8] zeroinitializer
define i8* @timlib_integer2binary(i32 %0) {
br label %2
2: ; preds = %1, %8
%3 = phi i32 [ %9, %8 ], [ 0, %1 ]
%4 = phi i8* [ %10, %8 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @timlib_integer2binary.binary, i64 0, i64 31), %1 ]
%5 = tail call i64 @getbits(i32 %0, i32 %3, i32 1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %2
store i8 49, i8* %4
br label %8
8: ; preds = %2, %7
%9 = add nuw nsw i32 %3, 1
%10 = getelementptr inbounds i8, i8* %4, i64 -1
%11 = icmp eq i32 %9, 32
br i1 %11, label %12, label %2
12: ; preds = %8
ret i8* getelementptr inbounds ([33 x i8], [33 x i8]* @timlib_integer2binary.binary, i64 0, i64 0)
}