#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 /*<<< orphan*/ strcat(char *, char *);
char *binary(char *chaine, unsigned char valeur) {
  int dep = 128;
  int i = 0;
  for (i = 0; i < 8; i++) {
    if (valeur - dep >= 0) {
      valeur -= dep;
      strcat(chaine, "1");
    } else {
      strcat(chaine, "0");
    }
    dep = dep / 2;
  }
  return (chaine);
}


x86 assembly (clang, -O0):
<binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x80,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    119e <binary+0x8e>
movzbl -0x9(%rbp),%eax
sub    -0x10(%rbp),%eax
cmp    $0x0,%eax
jl     1172 <binary+0x62>
mov    -0x10(%rbp),%ecx
movzbl -0x9(%rbp),%eax
sub    %ecx,%eax
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <strcat@plt>
jmp    1182 <binary+0x72>
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <binary+0x27>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r12
test   %bpl,%bpl
lea    0xed9(%rip),%r14
lea    0xed4(%rip),%r15
mov    %r15,%rsi
cmovs  %r14,%rsi
mov    %ebp,%ebx
and    $0x7f,%bl
call   1030 <strcat@plt>
and    $0x7f,%ebp
cmp    $0x3f,%bl
jbe    11e1 <binary+0xd1>
add    $0xc0,%ebp
lea    0xea8(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
movzbl %bpl,%ebp
cmp    $0x1f,%ebp
ja     11f9 <binary+0xe9>
lea    0xe8e(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
cmp    $0xf,%ebp
ja     121b <binary+0x10b>
lea    0xe76(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
cmp    $0x7,%ebp
ja     123d <binary+0x12d>
lea    0xe5e(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
cmp    $0x3,%ebp
ja     125f <binary+0x14f>
lea    0xe46(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
cmp    $0x1,%ebp
ja     1281 <binary+0x171>
lea    0xe2e(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
jmp    129a <binary+0x18a>
lea    0xe1a(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
cmp    $0x1f,%ebp
jbe    116d <binary+0x5d>
add    $0xe0,%ebp
lea    0xdfa(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
movzbl %bpl,%ebp
cmp    $0xf,%ebp
jbe    1185 <binary+0x75>
add    $0xf0,%ebp
lea    0xdd8(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
movzbl %bpl,%ebp
cmp    $0x7,%ebp
jbe    119d <binary+0x8d>
add    $0xf8,%ebp
lea    0xdb6(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
movzbl %bpl,%ebp
cmp    $0x3,%ebp
jbe    11b5 <binary+0xa5>
add    $0xfc,%ebp
lea    0xd94(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
movzbl %bpl,%ebp
cmp    $0x1,%ebp
jbe    11cd <binary+0xbd>
add    $0xfe,%ebp
lea    0xd72(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcat@plt>
movzbl %bpl,%ebp
test   %ebp,%ebp
cmove  %r15,%r14
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <strcat@plt>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define i8* @binary(i8* %0, i8 zeroext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8 %1, i8* %4
store i32 128, i32* %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %7
7: ; preds = %30, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %33
10: ; preds = %7
%11 = load i8, i8* %4
%12 = zext i8 %11 to i32
%13 = load i32, i32* %5
%14 = sub nsw i32 %12, %13
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %10
%17 = load i32, i32* %5
%18 = load i8, i8* %4
%19 = zext i8 %18 to i32
%20 = sub nsw i32 %19, %17
%21 = trunc i32 %20 to i8
store i8 %21, i8* %4
%22 = load i8*, i8** %3
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %27
24: ; preds = %10
%25 = load i8*, i8** %3
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %24, %16
%28 = load i32, i32* %5
%29 = sdiv i32 %28, 2
store i32 %29, i32* %5
br label %30
30: ; preds = %27
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %7
33: ; preds = %7
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define i8* @binary(i8* returned %0, i8 zeroext %1) {
%3 = icmp slt i8 %1, 0
%4 = select i1 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%5 = and i8 %1, 127
%6 = tail call i32 @strcat(i8* %0, i8* %4)
%7 = zext i8 %5 to i32
%8 = icmp ugt i8 %5, 63
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %15
11: ; preds = %2
%12 = add nuw nsw i32 %7, 192
%13 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = and i32 %12, 255
br label %15
15: ; preds = %11, %9
%16 = phi i32 [ %14, %11 ], [ %7, %9 ]
%17 = icmp ugt i32 %16, 31
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %24
20: ; preds = %15
%21 = add nuw nsw i32 %16, 224
%22 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = and i32 %21, 255
br label %24
24: ; preds = %20, %18
%25 = phi i32 [ %23, %20 ], [ %16, %18 ]
%26 = icmp ugt i32 %25, 15
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %33
29: ; preds = %24
%30 = add nuw nsw i32 %25, 240
%31 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%32 = and i32 %30, 255
br label %33
33: ; preds = %29, %27
%34 = phi i32 [ %32, %29 ], [ %25, %27 ]
%35 = icmp ugt i32 %34, 7
br i1 %35, label %38, label %36
36: ; preds = %33
%37 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %42
38: ; preds = %33
%39 = add nuw nsw i32 %34, 248
%40 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%41 = and i32 %39, 255
br label %42
42: ; preds = %38, %36
%43 = phi i32 [ %41, %38 ], [ %34, %36 ]
%44 = icmp ugt i32 %43, 3
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %51
47: ; preds = %42
%48 = add nuw nsw i32 %43, 252
%49 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%50 = and i32 %48, 255
br label %51
51: ; preds = %47, %45
%52 = phi i32 [ %50, %47 ], [ %43, %45 ]
%53 = icmp ugt i32 %52, 1
br i1 %53, label %56, label %54
54: ; preds = %51
%55 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %60
56: ; preds = %51
%57 = add nuw nsw i32 %52, 254
%58 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%59 = and i32 %57, 255
br label %60
60: ; preds = %56, %54
%61 = phi i32 [ %59, %56 ], [ %52, %54 ]
%62 = icmp eq i32 %61, 0
%63 = select i1 %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%64 = tail call i32 @strcat(i8* %0, i8* %63)
ret i8* %0
}