#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 *);
int main() {
  int z, n, a, x;
  printf("Zu teilende Zahl: ");
  scanf("%d", &z);
  printf("Teiler: ");
  scanf("%d", &n);
  printf("Anzahl Nachkommastellen: ");
  scanf("%d", &a);
  x = z / n;
  printf("Ergebnis = %d.", x);
  for (; a > 0; a = a - 1) {
    z = 10 * (z - n * x);
    if (z == 0)
      break;
    x = z / n;
    printf("%d", x);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jle    11f8 <main+0xd8>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x14(%rbp),%ecx
sub    %ecx,%eax
imul   $0xa,%eax,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11cf <main+0xaf>
jmp    11f8 <main+0xd8>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a4 <main+0x84>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec7(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
cltd
idivl  0x14(%rsp)
mov    %eax,%ebx
lea    0xe98(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11fc <main+0xcc>
lea    0xe5b(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%ecx
imul   %ecx,%ebx
sub    %ebx,%edx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %eax,0x10(%rsp)
test   %edx,%edx
je     11fc <main+0xcc>
cltd
idiv   %ecx
mov    %eax,%ebx
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0xc(%rsp)
cmp    $0x1,%eax
jg     11c0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Zu teilende Zahl: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"Teiler: \00"
@.str.3 = [26 x i8] c"Anzahl Nachkommastellen: \00"
@.str.4 = [15 x i8] c"Ergebnis = %d.\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = sdiv i32 %12, %13
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %36, %0
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %39
20: ; preds = %17
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = load i32, i32* %5
%24 = mul nsw i32 %22, %23
%25 = sub nsw i32 %21, %24
%26 = mul nsw i32 10, %25
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %20
br label %39
30: ; preds = %20
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = sdiv i32 %31, %32
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 1
store i32 %38, i32* %4
br label %17
39: ; preds = %29, %17
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Zu teilende Zahl: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"Teiler: \00"
@.str.3 = [26 x i8] c"Anzahl Nachkommastellen: \00"
@.str.4 = [15 x i8] c"Ergebnis = %d.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = sdiv i32 %13, %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %33
19: ; preds = %0, %27
%20 = phi i32 [ %28, %27 ], [ %15, %0 ]
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = mul nsw i32 %22, %20
%24 = sub nsw i32 %21, %23
%25 = mul nsw i32 %24, 10
store i32 %25, i32* %1
%26 = icmp eq i32 %24, 0
br i1 %26, label %33, label %27
27: ; preds = %19
%28 = sdiv i32 %25, %22
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %3
%31 = add nsw i32 %30, -1
store i32 %31, i32* %3
%32 = icmp sgt i32 %30, 1
br i1 %32, label %19, label %33
33: ; preds = %27, %19, %0
%34 = call i32 @putchar(i32 10)
ret i32 0
}