#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 */
char *dec2bin(int);
scalar_t__ malloc(int);
char *int2bin(int a) {
  int result = 0;
  int a1, a2, a3 = 0;
  a1 = a % 16;
  a2 = a % 15;
  a3 = a % 13;
  char *a1c;
  char *a2c;
  char *a3c;
  a1c = (char *)malloc(sizeof(char) * 6);
  a2c = (char *)malloc(sizeof(char) * 6);
  a3c = (char *)malloc(sizeof(char) * 6);
  a1c = dec2bin(a1);
  a2c = dec2bin(a2);
  a3c = dec2bin(a3);
  char *atc;
  atc = (char *)malloc(sizeof(char) * 20);
  int i;
  for (i = 0; i < 4; i++) {
    atc[i] = a1c[i];
  }
  for (i = 0; i < 4; i++) {
    atc[i + 4] = a2c[i];
  }
  for (i = 0; i < 4; i++) {
    atc[i + 8] = a3c[i];
  }
  return atc;
}


x86 assembly (clang, -O0):
<int2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    $0x6,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x6,%edi
call   1030 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x6,%edi
call   1030 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <dec2bin@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <dec2bin@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <dec2bin@plt>
mov    %rax,-0x30(%rbp)
mov    $0x14,%edi
call   1030 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    11f4 <int2bin+0xd4>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11c6 <int2bin+0xa6>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    122e <int2bin+0x10e>
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x38(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11fb <int2bin+0xdb>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    1268 <int2bin+0x148>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x38(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x8,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1235 <int2bin+0x115>
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int2bin>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xf(%rbx),%eax
test   %edi,%edi
cmovns %edi,%eax
and    $0xfffffff0,%eax
movslq %edi,%r14
sub    %eax,%ebx
imul   $0xffffffff88888889,%r14,%rax
shr    $0x20,%rax
add    %r14d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x3,%eax
add    %ecx,%eax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,2),%eax
mov    %r14d,%ebp
sub    %eax,%ebp
imul   $0x4ec4ec4f,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%ecx
lea    (%rax,%rcx,4),%eax
sub    %eax,%r14d
mov    $0x6,%edi
call   1030 <malloc@plt>
mov    $0x6,%edi
call   1030 <malloc@plt>
mov    $0x6,%edi
call   1030 <malloc@plt>
mov    %ebx,%edi
call   1040 <dec2bin@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1040 <dec2bin@plt>
mov    %rax,%rbp
mov    %r14d,%edi
call   1040 <dec2bin@plt>
mov    %rax,%r14
mov    $0x14,%edi
call   1030 <malloc@plt>
mov    (%rbx),%cl
mov    %cl,(%rax)
mov    0x1(%rbx),%cl
mov    %cl,0x1(%rax)
mov    0x2(%rbx),%cl
mov    %cl,0x2(%rax)
mov    0x3(%rbx),%cl
mov    %cl,0x3(%rax)
mov    0x0(%rbp),%cl
mov    %cl,0x4(%rax)
mov    0x1(%rbp),%cl
mov    %cl,0x5(%rax)
mov    0x2(%rbp),%cl
mov    %cl,0x6(%rax)
mov    0x3(%rbp),%cl
mov    %cl,0x7(%rax)
mov    (%r14),%cl
mov    %cl,0x8(%rax)
mov    0x1(%r14),%cl
mov    %cl,0x9(%rax)
mov    0x2(%r14),%cl
mov    %cl,0xa(%rax)
mov    0x3(%r14),%cl
mov    %cl,0xb(%rax)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @int2bin(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %6
%12 = load i32, i32* %2
%13 = srem i32 %12, 16
store i32 %13, i32* %4
%14 = load i32, i32* %2
%15 = srem i32 %14, 15
store i32 %15, i32* %5
%16 = load i32, i32* %2
%17 = srem i32 %16, 13
store i32 %17, i32* %6
%18 = call i64 @malloc(i32 6)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %7
%20 = call i64 @malloc(i32 6)
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %8
%22 = call i64 @malloc(i32 6)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %9
%24 = load i32, i32* %4
%25 = call i8* @dec2bin(i32 %24)
store i8* %25, i8** %7
%26 = load i32, i32* %5
%27 = call i8* @dec2bin(i32 %26)
store i8* %27, i8** %8
%28 = load i32, i32* %6
%29 = call i8* @dec2bin(i32 %28)
store i8* %29, i8** %9
%30 = call i64 @malloc(i32 20)
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** %10
store i32 0, i32* %11
br label %32
32: ; preds = %45, %1
%33 = load i32, i32* %11
%34 = icmp slt i32 %33, 4
br i1 %34, label %35, label %48
35: ; preds = %32
%36 = load i8*, i8** %7
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = load i8*, i8** %10
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 %40, i8* %44
br label %45
45: ; preds = %35
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %32
48: ; preds = %32
store i32 0, i32* %11
br label %49
49: ; preds = %63, %48
%50 = load i32, i32* %11
%51 = icmp slt i32 %50, 4
br i1 %51, label %52, label %66
52: ; preds = %49
%53 = load i8*, i8** %8
%54 = load i32, i32* %11
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = load i8*, i8** %10
%59 = load i32, i32* %11
%60 = add nsw i32 %59, 4
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %58, i64 %61
store i8 %57, i8* %62
br label %63
63: ; preds = %52
%64 = load i32, i32* %11
%65 = add nsw i32 %64, 1
store i32 %65, i32* %11
br label %49
66: ; preds = %49
store i32 0, i32* %11
br label %67
67: ; preds = %81, %66
%68 = load i32, i32* %11
%69 = icmp slt i32 %68, 4
br i1 %69, label %70, label %84
70: ; preds = %67
%71 = load i8*, i8** %9
%72 = load i32, i32* %11
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = load i8, i8* %74
%76 = load i8*, i8** %10
%77 = load i32, i32* %11
%78 = add nsw i32 %77, 8
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %76, i64 %79
store i8 %75, i8* %80
br label %81
81: ; preds = %70
%82 = load i32, i32* %11
%83 = add nsw i32 %82, 1
store i32 %83, i32* %11
br label %67
84: ; preds = %67
%85 = load i8*, i8** %10
ret i8* %85
}

LLVM IR (-O2):
define i8* @int2bin(i32 %0) {
%2 = srem i32 %0, 16
%3 = srem i32 %0, 15
%4 = srem i32 %0, 13
%5 = tail call i64 @malloc(i32 6)
%6 = tail call i64 @malloc(i32 6)
%7 = tail call i64 @malloc(i32 6)
%8 = tail call i8* @dec2bin(i32 %2)
%9 = tail call i8* @dec2bin(i32 %3)
%10 = tail call i8* @dec2bin(i32 %4)
%11 = tail call i64 @malloc(i32 20)
%12 = inttoptr i64 %11 to i8*
%13 = load i8, i8* %8
store i8 %13, i8* %12
%14 = getelementptr inbounds i8, i8* %8, i64 1
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %8, i64 2
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %12, i64 2
store i8 %18, i8* %19
%20 = getelementptr inbounds i8, i8* %8, i64 3
%21 = load i8, i8* %20
%22 = getelementptr inbounds i8, i8* %12, i64 3
store i8 %21, i8* %22
%23 = load i8, i8* %9
%24 = getelementptr inbounds i8, i8* %12, i64 4
store i8 %23, i8* %24
%25 = getelementptr inbounds i8, i8* %9, i64 1
%26 = load i8, i8* %25
%27 = getelementptr inbounds i8, i8* %12, i64 5
store i8 %26, i8* %27
%28 = getelementptr inbounds i8, i8* %9, i64 2
%29 = load i8, i8* %28
%30 = getelementptr inbounds i8, i8* %12, i64 6
store i8 %29, i8* %30
%31 = getelementptr inbounds i8, i8* %9, i64 3
%32 = load i8, i8* %31
%33 = getelementptr inbounds i8, i8* %12, i64 7
store i8 %32, i8* %33
%34 = load i8, i8* %10
%35 = getelementptr inbounds i8, i8* %12, i64 8
store i8 %34, i8* %35
%36 = getelementptr inbounds i8, i8* %10, i64 1
%37 = load i8, i8* %36
%38 = getelementptr inbounds i8, i8* %12, i64 9
store i8 %37, i8* %38
%39 = getelementptr inbounds i8, i8* %10, i64 2
%40 = load i8, i8* %39
%41 = getelementptr inbounds i8, i8* %12, i64 10
store i8 %40, i8* %41
%42 = getelementptr inbounds i8, i8* %10, i64 3
%43 = load i8, i8* %42
%44 = getelementptr inbounds i8, i8* %12, i64 11
store i8 %43, i8* %44
ret i8* %12
}