#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int quersumme(int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int number;
  if (argc != 2) {
    printf("Zu wenig oder zu viele Argumente\n");
    return 1;
  }
  number = atoi(argv[1]);
  while (1) {
    if (number > 0) {
      printf("Die Zahl ist %d\n", number);
      printf("Ergebnis: %d\n", quersumme(number));
      return 0;
    }
    if (number < 0) {
      printf("Zahl kleiner 0 neue Zahl: ");
      scanf("%d", &number);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     117a <main+0x3a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f6 <main+0xb6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11c9 <main+0x89>
mov    -0x14(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <quersumme@plt>
mov    %eax,%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <main+0xb6>
cmpl   $0x0,-0x14(%rbp)
jge    11f1 <main+0xb1>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe74(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
jmp    118a <main+0x4a>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    119c <main+0x4c>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
jle    11b9 <main+0x69>
lea    0xe8a(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edi
call   1050 <quersumme@plt>
lea    0xe80(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ad <main+0x5d>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe5f(%rip),%r14
lea    0xe73(%rip),%r15
lea    0xc(%rsp),%rbx
jmp    11d4 <main+0x84>
xchg   %ax,%ax
test   %eax,%eax
jg     116f <main+0x1f>
test   %eax,%eax
mov    $0x0,%eax
jns    11d0 <main+0x80>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
jmp    11d0 <main+0x80>

LLVM IR (-O0):
@.str = [34 x i8] c"Zu wenig oder zu viele Argumente\0A\00"
@.str.1 = [17 x i8] c"Die Zahl ist %d\0A\00"
@.str.2 = [14 x i8] c"Ergebnis: %d\0A\00"
@.str.3 = [27 x i8] c"Zahl kleiner 0 neue Zahl: \00"
@.str.4 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %32
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %6
br label %16
16: ; preds = %11, %31
%17 = load i32, i32* %6
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load i32, i32* %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %6
%23 = call i32 @quersumme(i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %23)
store i32 0, i32* %3
br label %32
25: ; preds = %16
%26 = load i32, i32* %6
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
br label %31
31: ; preds = %28, %25
br label %16
32: ; preds = %19, %9
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str.1 = [17 x i8] c"Die Zahl ist %d\0A\00"
@.str.2 = [14 x i8] c"Ergebnis: %d\0A\00"
@.str.3 = [27 x i8] c"Zahl kleiner 0 neue Zahl: \00"
@.str.4 = [3 x i8] c"%d\00"
@str = [33 x i8] c"Zu wenig oder zu viele Argumente\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %29
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
store i32 %11, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %26, %8
%14 = phi i32 [ %11, %8 ], [ %27, %26 ]
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = call i32 @quersumme(i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %29
19: ; preds = %8, %26
%20 = phi i32 [ %27, %26 ], [ %11, %8 ]
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %3
br label %26
26: ; preds = %22, %19
%27 = phi i32 [ %25, %22 ], [ 0, %19 ]
%28 = icmp sgt i32 %27, 0
br i1 %28, label %13, label %19
29: ; preds = %13, %6
%30 = phi i32 [ 1, %6 ], [ 0, %13 ]
ret i32 %30
}