#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*/ ggt(unsigned long, unsigned long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  unsigned long a, b;
  int ende;
  printf("Programm zur Berechnung des größten gemeinsamen Teilers\n");
  do {
    printf("1: GGT bestimmen\n2: Programm beenden\n");
    scanf("%d", &ende);
    if (ende != 2) {
      printf("Zahl 1: ");
      scanf("%lu", &a);
      printf("Zahl 2: ");
      scanf("%lu", &b);
      printf("Der ggT von %lu und %lu ist %lu\n", a, b, ggt(a, b));
    }
  } while (ende != 2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x2,-0x1c(%rbp)
je     11ec <main+0xbc>
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <ggt@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f1 <main+0xc1>
cmpl   $0x2,-0x1c(%rbp)
jne    114d <main+0x1d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rbx
lea    0xea8(%rip),%r14
lea    0x8(%rsp),%r12
lea    0xea5(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6d(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x2,0x4(%rsp)
je     120c <main+0xcc>
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x10(%rsp),%rbp
mov    0x8(%rsp),%r13
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <ggt@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x2,0x4(%rsp)
jne    1180 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [59 x i8] c"Programm zur Berechnung des gr\C3\B6\C3\9Ften gemeinsamen Teilers\0A\00"
@.str.1 = [38 x i8] c"1: GGT bestimmen\0A2: Programm beenden\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [9 x i8] c"Zahl 1: \00"
@.str.4 = [4 x i8] c"%lu\00"
@.str.5 = [9 x i8] c"Zahl 2: \00"
@.str.6 = [33 x i8] c"Der ggT von %lu und %lu ist %lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %23, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %22
11: ; preds = %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64* %2)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64* %3)
%16 = load i64, i64* %2
%17 = load i64, i64* %3
%18 = load i64, i64* %2
%19 = load i64, i64* %3
%20 = call i32 @ggt(i64 %18, i64 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i64 %16, i64 %17, i32 %20)
br label %22
22: ; preds = %11, %6
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 2
br i1 %25, label %6, label %26
26: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [9 x i8] c"Zahl 1: \00"
@.str.4 = [4 x i8] c"%lu\00"
@.str.5 = [9 x i8] c"Zahl 2: \00"
@.str.6 = [33 x i8] c"Der ggT von %lu und %lu ist %lu\0A\00"
@str = [58 x i8] c"Programm zur Berechnung des gr\C3\B6\C3\9Ften gemeinsamen Teilers\00"
@str.7 = [37 x i8] c"1: GGT bestimmen\0A2: Programm beenden\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i32
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %13, %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 2
br i1 %12, label %24, label %13
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64* %1)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64* %2)
%18 = load i64, i64* %1
%19 = load i64, i64* %2
%20 = call i32 @ggt(i64 %18, i64 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i64 %18, i64 %19, i32 %20)
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %8
24: ; preds = %8, %13
ret i32 0
}