#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int run = 1, i, mhalf, scanfres = 0, m, n;
  srand(time(NULL));
  printf("Primzahlen\n");
  printf("==========\n");
  do {
    printf("Geben Sie den Bereich (m,n ; n > m > 0) ein,\nfuer den die "
           "Primzahlen ausgegeben werden sollen: ");
    scanfres = scanf("%d,%d", &m, &n);
    fflush(stdin);
  } while (scanfres != 2 || m >= n || n < 2 || m < 1);
  while (m <= n) {
    mhalf = m / 2;
    int prime = 1;
    for (i = 2; i <= mhalf; i++)
      if (!(m % i)) {
        prime = 0;
        break;
      }
    if (prime)
      printf("%8d,", m);
    m++;
  }
  fflush(stdin);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1080 <scanf@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x1,%al
cmpl   $0x2,-0x14(%rbp)
mov    %al,-0x21(%rbp)
jne    1215 <main+0xb5>
mov    -0x18(%rbp),%ecx
mov    $0x1,%al
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x21(%rbp)
jge    1215 <main+0xb5>
mov    $0x1,%al
cmpl   $0x2,-0x1c(%rbp)
mov    %al,-0x21(%rbp)
jl     1215 <main+0xb5>
cmpl   $0x1,-0x18(%rbp)
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11a9 <main+0x49>
jmp    1225 <main+0xc5>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     12b1 <main+0x151>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1288 <main+0x128>
mov    -0x18(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1275 <main+0x115>
movl   $0x0,-0x20(%rbp)
jmp    1288 <main+0x128>
jmp    127a <main+0x11a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    124d <main+0xed>
cmpl   $0x0,-0x20(%rbp)
je     12a3 <main+0x143>
mov    -0x18(%rbp),%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1225 <main+0xc5>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
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
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
lea    0xe58(%rip),%r14
lea    0xeb1(%rip),%r15
mov    %rsp,%r12
lea    0x4(%rsp),%rbx
mov    0x2e2a(%rip),%r13
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1090 <scanf@plt>
mov    %eax,%ebp
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
cmp    $0x2,%ebp
jne    11c0 <main+0x50>
mov    (%rsp),%esi
test   %esi,%esi
jle    11c0 <main+0x50>
mov    0x4(%rsp),%ecx
cmp    %ecx,%esi
jge    11c0 <main+0x50>
cmp    $0x2,%ecx
jl     11c0 <main+0x50>
lea    0xe63(%rip),%rbx
jmp    122d <main+0xbd>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%ecx
lea    0x1(%rsi),%eax
mov    %eax,(%rsp)
cmp    %ecx,%esi
mov    %eax,%esi
jge    125d <main+0xed>
cmp    $0x4,%esi
jl     1210 <main+0xa0>
mov    %esi,%edi
shr    %edi
neg    %edi
mov    $0x2,%ebp
nopl   (%rax)
mov    %esi,%eax
cltd
idiv   %ebp
test   %edx,%edx
je     1221 <main+0xb1>
lea    (%rdi,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%edx
add    $0x1,%edx
mov    %edx,%ebp
cmp    $0x1,%eax
jne    1240 <main+0xd0>
jmp    1210 <main+0xa0>
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Primzahlen\0A\00"
@.str.1 = [12 x i8] c"==========\0A\00"
@.str.2 = [96 x i8] c"Geben Sie den Bereich (m,n ; n > m > 0) ein,\0Afuer den die Primzahlen ausgegeben werden sollen: \00"
@.str.3 = [6 x i8] c"%d,%d\00"
@stdin = global i32 0
@.str.4 = [5 x i8] c"%8d,\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 0, i32* %5
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %31, %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %6, i32* %7)
store i32 %15, i32* %5
%16 = load i32, i32* @stdin
%17 = call i32 @fflush(i32 %16)
br label %18
18: ; preds = %13
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 2
br i1 %20, label %31, label %21
21: ; preds = %18
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = icmp sge i32 %22, %23
br i1 %24, label %31, label %25
25: ; preds = %21
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 2
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 1
br label %31
31: ; preds = %28, %25, %21, %18
%32 = phi i1 [ true, %25 ], [ true, %21 ], [ true, %18 ], [ %30, %28 ]
br i1 %32, label %13, label %33
33: ; preds = %31
br label %34
34: ; preds = %61, %33
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = icmp sle i32 %35, %36
br i1 %37, label %38, label %64
38: ; preds = %34
%39 = load i32, i32* %6
%40 = sdiv i32 %39, 2
store i32 %40, i32* %4
store i32 1, i32* %8
store i32 2, i32* %3
br label %41
41: ; preds = %52, %38
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = icmp sle i32 %42, %43
br i1 %44, label %45, label %55
45: ; preds = %41
%46 = load i32, i32* %6
%47 = load i32, i32* %3
%48 = srem i32 %46, %47
%49 = icmp ne i32 %48, 0
br i1 %49, label %51, label %50
50: ; preds = %45
store i32 0, i32* %8
br label %55
51: ; preds = %45
br label %52
52: ; preds = %51
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %41
55: ; preds = %50, %41
%56 = load i32, i32* %8
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load i32, i32* %6
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %58, %55
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %34
64: ; preds = %34
%65 = load i32, i32* @stdin
%66 = call i32 @fflush(i32 %65)
%67 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [96 x i8] c"Geben Sie den Bereich (m,n ; n > m > 0) ein,\0Afuer den die Primzahlen ausgegeben werden sollen: \00"
@.str.3 = [6 x i8] c"%d,%d\00"
@stdin = global i32 0
@.str.4 = [5 x i8] c"%8d,\00"
@str = [11 x i8] c"Primzahlen\00"
@str.5 = [11 x i8] c"==========\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0))
br label %9
9: ; preds = %23, %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([96 x i8], [96 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2)
%12 = load i32, i32* @stdin
%13 = call i32 @fflush(i32 %12)
%14 = icmp eq i32 %11, 2
br i1 %14, label %15, label %23
15: ; preds = %9
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = icmp sge i32 %16, %17
%19 = icmp slt i32 %17, 2
%20 = or i1 %18, %19
%21 = icmp slt i32 %16, 1
%22 = or i1 %21, %20
br i1 %22, label %23, label %24
23: ; preds = %15, %9
br label %9
24: ; preds = %15, %41
%25 = phi i32 [ %42, %41 ], [ %17, %15 ]
%26 = phi i32 [ %44, %41 ], [ %16, %15 ]
%27 = icmp slt i32 %26, 4
br i1 %27, label %37, label %28
28: ; preds = %24
%29 = lshr i32 %26, 1
br label %33
30: ; preds = %33
%31 = add nuw nsw i32 %34, 1
%32 = icmp eq i32 %34, %29
br i1 %32, label %37, label %33
33: ; preds = %28, %30
%34 = phi i32 [ %31, %30 ], [ 2, %28 ]
%35 = srem i32 %26, %34
%36 = icmp eq i32 %35, 0
br i1 %36, label %41, label %30
37: ; preds = %30, %24
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%39 = load i32, i32* %1
%40 = load i32, i32* %2
br label %41
41: ; preds = %33, %37
%42 = phi i32 [ %40, %37 ], [ %25, %33 ]
%43 = phi i32 [ %39, %37 ], [ %26, %33 ]
%44 = add nsw i32 %43, 1
store i32 %44, i32* %1
%45 = icmp slt i32 %43, %42
br i1 %45, label %24, label %46
46: ; preds = %41
%47 = load i32, i32* @stdin
%48 = call i32 @fflush(i32 %47)
%49 = call i32 (...) @getchar()
ret i32 0
}