#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main() {
  int zahl, divisor, obergrenze, primzahl;
  printf("\n\n\t\tBitte geben Sie eine Obergrenze ein:\n\n\t\t--> ");
  scanf("%d", &obergrenze);
  fflush(stdin);
  printf("\n\t\tEs folgen die Primzahlen zwischen 1 und %d:\n\n", obergrenze);
  for (zahl = 1; zahl <= obergrenze; zahl++) {
    primzahl = 1;
    for (divisor = 2; divisor < zahl; divisor++) {
      if (zahl % divisor == 0) {
        primzahl = 0;
      }
    }
    if (primzahl) {
      printf("\t\t- %d\n", zahl);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x10(%rbp),%esi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1201 <main+0xd1>
movl   $0x1,-0x14(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d3 <main+0xa3>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11c0 <main+0x90>
movl   $0x0,-0x14(%rbp)
jmp    11c5 <main+0x95>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119d <main+0x6d>
cmpl   $0x0,-0x14(%rbp)
je     11ee <main+0xbe>
mov    -0x8(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f3 <main+0xc3>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1183 <main+0x53>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0xc(%rsp),%esi
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%r9d
test   %r9d,%r9d
jle    1268 <main+0x128>
mov    $0x1,%ebx
mov    $0xffffffff,%r15d
lea    0xeba(%rip),%r14
xor    %r12d,%r12d
jmp    11db <main+0x9b>
test   %edi,%edi
je     11c5 <main+0x85>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%r9d
lea    0x1(%rbx),%eax
add    $0x1,%r12d
add    $0x1,%r15d
cmp    %r9d,%ebx
mov    %eax,%ebx
jge    1268 <main+0x128>
cmp    $0x3,%ebx
jb     11b4 <main+0x74>
lea    -0x1(%r12),%r8d
cmp    $0x2,%r12d
jne    1200 <main+0xc0>
mov    $0x2,%ecx
mov    $0x1,%edi
jmp    124e <main+0x10e>
nopw   0x0(%rax,%rax,1)
mov    %r15d,%r10d
and    $0xfffffffe,%r10d
neg    %r10d
mov    $0x2,%ebp
mov    $0x1,%edi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
mov    %edx,%ecx
lea    0x1(%rbp),%esi
mov    %ebx,%eax
xor    %edx,%edx
div    %esi
test   %ecx,%ecx
cmove  %ecx,%edi
test   %edx,%edx
cmove  %edx,%edi
mov    %ebp,%ecx
add    $0x2,%ecx
lea    (%r10,%rbp,1),%eax
add    $0x2,%eax
mov    %ecx,%ebp
cmp    $0x2,%eax
jne    1220 <main+0xe0>
test   $0x1,%r8b
je     11b0 <main+0x70>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
test   %edx,%edx
cmove  %edx,%edi
jmp    11b0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"\0A\0A\09\09Bitte geben Sie eine Obergrenze ein:\0A\0A\09\09--> \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.2 = [49 x i8] c"\0A\09\09Es folgen die Primzahlen zwischen 1 und %d:\0A\0A\00"
@.str.3 = [8 x i8] c"\09\09- %d\0A\00"
@.str.4 = [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 ([49 x i8], [49 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* %4)
%8 = load i32, i32* @stdin
%9 = call i32 @fflush(i32 %8)
%10 = load i32, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %10)
store i32 1, i32* %2
br label %12
12: ; preds = %38, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %4
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %41
16: ; preds = %12
store i32 1, i32* %5
store i32 2, i32* %3
br label %17
17: ; preds = %28, %16
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = srem i32 %22, %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 0, i32* %5
br label %27
27: ; preds = %26, %21
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %17
31: ; preds = %17
%32 = load i32, i32* %5
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* %2
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %34, %31
br label %38
38: ; preds = %37
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
br label %12
41: ; preds = %12
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [49 x i8] c"\0A\0A\09\09Bitte geben Sie eine Obergrenze ein:\0A\0A\09\09--> \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.2 = [49 x i8] c"\0A\09\09Es folgen die Primzahlen zwischen 1 und %d:\0A\0A\00"
@.str.3 = [8 x i8] c"\09\09- %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* @stdin
%6 = call i32 @fflush(i32 %5)
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 1
br i1 %10, label %56, label %11
11: ; preds = %0, %51
%12 = phi i32 [ %55, %51 ], [ 0, %0 ]
%13 = phi i32 [ %52, %51 ], [ %9, %0 ]
%14 = phi i32 [ %53, %51 ], [ 1, %0 ]
%15 = add i32 %12, -1
%16 = icmp ugt i32 %14, 2
br i1 %16, label %17, label %48
17: ; preds = %11
%18 = and i32 %15, 1
%19 = icmp eq i32 %12, 2
br i1 %19, label %36, label %20
20: ; preds = %17
%21 = and i32 %15, -2
br label %22
22: ; preds = %22, %20
%23 = phi i32 [ 1, %20 ], [ %32, %22 ]
%24 = phi i32 [ 2, %20 ], [ %33, %22 ]
%25 = phi i32 [ 0, %20 ], [ %34, %22 ]
%26 = urem i32 %14, %24
%27 = icmp eq i32 %26, 0
%28 = or i32 %24, 1
%29 = urem i32 %14, %28
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i1 true, i1 %27
%32 = select i1 %31, i32 0, i32 %23
%33 = add nuw nsw i32 %24, 2
%34 = add i32 %25, 2
%35 = icmp eq i32 %34, %21
br i1 %35, label %36, label %22
36: ; preds = %22, %17
%37 = phi i32 [ undef, %17 ], [ %32, %22 ]
%38 = phi i32 [ 1, %17 ], [ %32, %22 ]
%39 = phi i32 [ 2, %17 ], [ %33, %22 ]
%40 = icmp eq i32 %18, 0
br i1 %40, label %45, label %41
41: ; preds = %36
%42 = urem i32 %14, %39
%43 = icmp eq i32 %42, 0
%44 = select i1 %43, i32 0, i32 %38
br label %45
45: ; preds = %36, %41
%46 = phi i32 [ %37, %36 ], [ %44, %41 ]
%47 = icmp eq i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %11, %45
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%50 = load i32, i32* %1
br label %51
51: ; preds = %45, %48
%52 = phi i32 [ %13, %45 ], [ %50, %48 ]
%53 = add nuw nsw i32 %14, 1
%54 = icmp slt i32 %14, %52
%55 = add i32 %12, 1
br i1 %54, label %11, label %56
56: ; preds = %51, %0
%57 = call i32 @putchar(i32 10)
ret i32 0
}