#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 get_machine_type();
int /*<<< orphan*/ hack_und_patch();
int lookup(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  unsigned int y, pair = 0;
  if (get_machine_type() == 1) {
    printf("Ich bin ein KC85/4\n");
    hack_und_patch();
  } else {
    printf("Ich bin ein KC85/2 oder KC85/3\n");
  }
  printf("Bildschirmadressen\n (neu berechnet):\n");
  for (y = 0; y < 256; y += 8) {
    pair = 256 * y;
    printf("%04x: ", pair);
    printf("%04x ", lookup(pair | 0));
    printf("%04x ", lookup(pair | 0x1f));
    printf("%04x ", lookup(pair | 0x20));
    printf("%04x ", lookup(pair | 0x28));
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1060 <get_machine_type@plt>
cmp    $0x1,%eax
jne    1179 <main+0x39>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <hack_und_patch@plt>
jmp    1187 <main+0x47>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x100,-0x4(%rbp)
jae    124b <main+0x10b>
mov    -0x4(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
or     $0x0,%edi
call   1040 <lookup@plt>
mov    %eax,%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
or     $0x1f,%edi
call   1040 <lookup@plt>
mov    %eax,%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
or     $0x20,%edi
call   1040 <lookup@plt>
mov    %eax,%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
or     $0x28,%edi
call   1040 <lookup@plt>
mov    %eax,%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x4(%rbp)
jmp    119c <main+0x5c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <get_machine_type@plt>
cmp    $0x1,%eax
jne    1188 <main+0x28>
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1070 <hack_und_patch@plt>
jmp    1194 <main+0x34>
lea    0xe7e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe91(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffff8,%ebp
lea    0xe54(%rip),%r14
lea    0xe54(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1060 <lookup@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1f(%rbx),%edi
call   1060 <lookup@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x20(%rbx),%edi
call   1060 <lookup@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x28(%rbx),%edi
call   1060 <lookup@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x8,%ebp
add    $0x800,%ebx
cmp    $0xf8,%ebp
jb     11c0 <main+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Ich bin ein KC85/4\0A\00"
@.str.1 = [32 x i8] c"Ich bin ein KC85/2 oder KC85/3\0A\00"
@.str.2 = [38 x i8] c"Bildschirmadressen\0A (neu berechnet):\0A\00"
@.str.3 = [7 x i8] c"%04x: \00"
@.str.4 = [6 x i8] c"%04x \00"
@.str.5 = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
%3 = call i32 (...) @get_machine_type()
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @hack_und_patch()
br label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %12
12: ; preds = %37, %10
%13 = load i32, i32* %1
%14 = icmp ult i32 %13, 256
br i1 %14, label %15, label %40
15: ; preds = %12
%16 = load i32, i32* %1
%17 = mul i32 256, %16
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = or i32 %20, 0
%22 = call i32 @lookup(i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %2
%25 = or i32 %24, 31
%26 = call i32 @lookup(i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %2
%29 = or i32 %28, 32
%30 = call i32 @lookup(i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %2
%33 = or i32 %32, 40
%34 = call i32 @lookup(i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %15
%38 = load i32, i32* %1
%39 = add i32 %38, 8
store i32 %39, i32* %1
br label %12
40: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str.3 = [7 x i8] c"%04x: \00"
@.str.4 = [6 x i8] c"%04x \00"
@str = [31 x i8] c"Ich bin ein KC85/2 oder KC85/3\00"
@str.6 = [37 x i8] c"Bildschirmadressen\0A (neu berechnet):\00"
@str.7 = [19 x i8] c"Ich bin ein KC85/4\00"
define void @main() {
%1 = tail call i32 (...) @get_machine_type()
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%5 = tail call i32 (...) @hack_und_patch()
br label %8
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.6, i64 0, i64 0))
br label %10
10: ; preds = %8, %10
%11 = phi i32 [ 0, %8 ], [ %26, %10 ]
%12 = shl nuw nsw i32 %11, 8
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = tail call i32 @lookup(i32 %12)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = or i32 %12, 31
%17 = tail call i32 @lookup(i32 %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = or i32 %12, 32
%20 = tail call i32 @lookup(i32 %19)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = or i32 %12, 40
%23 = tail call i32 @lookup(i32 %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = tail call i32 @putchar(i32 10)
%26 = add nuw nsw i32 %11, 8
%27 = icmp ult i32 %11, 248
br i1 %27, label %10, label %28
28: ; preds = %10
ret void
}