#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int index[32], dezimalzahl, i;
  printf("Geben Sie eine Dezimalzahl ein:\n");
  scanf("%d", &dezimalzahl);
  for (i = 0; dezimalzahl > 0; i++) {
    index[i] = dezimalzahl % 2;
    dezimalzahl = dezimalzahl / 2;
  }
  for (; i > 0; i--) {
    printf("%d", index[i - 1]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x94(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x98(%rbp)
cmpl   $0x0,-0x94(%rbp)
jle    11ae <main+0x8e>
mov    -0x94(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq -0x98(%rbp),%rax
mov    %edx,-0x90(%rbp,%rax,4)
mov    -0x94(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x94(%rbp)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    115d <main+0x3d>
jmp    11b3 <main+0x93>
cmpl   $0x0,-0x98(%rbp)
jle    11f4 <main+0xd4>
mov    -0x98(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x90(%rbp,%rax,4),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x98(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x98(%rbp)
jmp    11b3 <main+0x93>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x98,%rsp
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11b8 <main+0x88>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%ecx
mov    %eax,%edx
and    $0x1,%edx
mov    %edx,0x10(%rsp,%rbx,4)
shr    %eax
add    $0x1,%rbx
cmp    $0x2,%ecx
jae    1170 <main+0x40>
mov    %eax,0xc(%rsp)
test   %ebx,%ebx
jle    11b8 <main+0x88>
add    $0x1,%rbx
lea    0xe67(%rip),%r14
nopl   0x0(%rax)
mov    0x8(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11a0 <main+0x70>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Geben Sie eine Dezimalzahl ein:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i32, i32* %3
%12 = srem i32 %11, 2
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 %14
store i32 %12, i32* %15
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 2
store i32 %17, i32* %3
br label %18
18: ; preds = %10
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %7
21: ; preds = %7
br label %22
22: ; preds = %32, %21
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = load i32, i32* %4
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %4
%34 = add nsw i32 %33, -1
store i32 %34, i32* %4
br label %22
35: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [32 x i8] c"Geben Sie eine Dezimalzahl ein:\00"
define i32 @main() {
%1 = alloca [32 x i32]
%2 = alloca i32
%3 = bitcast [32 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %14, label %29
9: ; preds = %14
%10 = trunc i64 %20 to i32
store i32 %19, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = and i64 %20, 4294967295
br label %22
14: ; preds = %0, %14
%15 = phi i64 [ %20, %14 ], [ 0, %0 ]
%16 = phi i32 [ %19, %14 ], [ %7, %0 ]
%17 = and i32 %16, 1
%18 = getelementptr inbounds [32 x i32], [32 x i32]* %1, i64 0, i64 %15
store i32 %17, i32* %18
%19 = lshr i32 %16, 1
%20 = add nuw nsw i64 %15, 1
%21 = icmp ult i32 %16, 2
br i1 %21, label %9, label %14
22: ; preds = %12, %22
%23 = phi i64 [ %13, %12 ], [ %24, %22 ]
%24 = add nsw i64 %23, -1
%25 = getelementptr inbounds [32 x i32], [32 x i32]* %1, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = icmp ugt i64 %23, 1
br i1 %28, label %22, label %29
29: ; preds = %22, %0, %9
ret i32 0
}