#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*/ fgets(char *, int const, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int const);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  static const int maxdata = sizeof(int) * 2;
  static const int taxrate1 = 2;
  static const int taxlevel1 = 450000;
  static const int taxrate2 = 4;
  static const int taxlevel2 = 600000;
  static const int taxrate3 = 6;
  static const int taxlevel3 = 750000;
  static const int taxrate4 = 8;
  int taxvalue;
  float tax = 0;
  char *indata = malloc(maxdata);
  if (indata == NULL) {
    printf("Out of memory");
    return 1;
  }
  printf("Mata in taxeringsvärdet på din fastighet: ");
  fgets(indata, maxdata, stdin);
  taxvalue = atoi(indata);
  if (taxvalue > taxlevel3) {
    tax += ((taxvalue - taxlevel3) / 100.0) * taxrate4;
    taxvalue -= (taxvalue - taxlevel3);
  }
  if (taxvalue > taxlevel2) {
    tax += ((taxvalue - taxlevel2) / 100.0) * taxrate3;
    taxvalue -= (taxvalue - taxlevel2);
  }
  if (taxvalue > taxlevel1) {
    tax += ((taxvalue - taxlevel1) / 100.0) * taxrate2;
    taxvalue -= (taxvalue - taxlevel1);
  }
  if (taxvalue <= taxlevel1) {
    tax += (taxvalue / 100) * taxrate1;
  }
  printf("Du borde betala %.0f i skatt\n", tax);
  free(indata);
  indata = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119a <main+0x4a>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    132b <main+0x1db>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1050 <fgets@plt>
mov    -0x18(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xb71b0,-0x8(%rbp)
jle    1223 <main+0xd3>
mov    -0x8(%rbp),%eax
sub    $0xb71b0,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe1c(%rip),%xmm1
divsd  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xdff(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
sub    $0xb71b0,%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x927c0,-0x8(%rbp)
jle    127b <main+0x12b>
mov    -0x8(%rbp),%eax
sub    $0x927c0,%eax
cvtsi2sd %eax,%xmm0
movsd  0xdc4(%rip),%xmm1
divsd  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xdb7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
sub    $0x927c0,%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x6ddd0,-0x8(%rbp)
jle    12d3 <main+0x183>
mov    -0x8(%rbp),%eax
sub    $0x6ddd0,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd6c(%rip),%xmm1
divsd  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xd67(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
sub    $0x6ddd0,%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x6ddd0,-0x8(%rbp)
jg     12fc <main+0x1ac>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
shl    $0x1,%eax
cvtsi2ss %eax,%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd6f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x8,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11c9 <main+0x79>
mov    %rax,%rbx
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1070 <atoi@plt>
cmp    $0xb71b1,%eax
jl     11de <main+0x8e>
add    $0xfff48e50,%eax
cvtsi2sd %eax,%xmm0
divsd  0xe59(%rip),%xmm0
mulsd  0xe59(%rip),%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0xb71b0,%eax
jmp    11ec <main+0x9c>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
pop    %rbx
ret
xorps  %xmm0,%xmm0
cmp    $0x927c1,%eax
jl     128c <main+0x13c>
add    $0xfff6d840,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  0xe00(%rip),%xmm1
mulsd  0xe08(%rip),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mov    $0x927c0,%eax
add    $0xfff92230,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xdcd(%rip),%xmm0
mulsd  0xddd(%rip),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    $0x6ddd0,%eax
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
add    %eax,%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xde2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
cmp    $0x6ddd1,%eax
jge    121f <main+0xcf>
jmp    1248 <main+0xf8>

LLVM IR (-O0):
@main.maxdata = internal constant i32 8
@main.taxrate1 = internal constant i32 2
@main.taxlevel1 = internal constant i32 450000
@main.taxrate2 = internal constant i32 4
@main.taxlevel2 = internal constant i32 600000
@main.taxrate3 = internal constant i32 6
@main.taxlevel3 = internal constant i32 750000
@main.taxrate4 = internal constant i32 8
@.str = [14 x i8] c"Out of memory\00"
@.str.1 = [45 x i8] c"Mata in taxeringsv\C3\A4rdet p\C3\A5 din fastighet: \00"
@stdin = global i32 0
@.str.2 = [30 x i8] c"Du borde betala %.0f i skatt\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca i8*
store i32 0, i32* %1
store float 0.000000e+00, float* %3
%5 = call i8* @malloc(i32 8)
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %80
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%12 = load i8*, i8** %4
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 8, i32 %13)
%15 = load i8*, i8** %4
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 750000
br i1 %18, label %19, label %32
19: ; preds = %10
%20 = load i32, i32* %2
%21 = sub nsw i32 %20, 750000
%22 = sitofp i32 %21 to double
%23 = fdiv double %22, 1.000000e+02
%24 = load float, float* %3
%25 = fpext float %24 to double
%26 = call double @llvm.fmuladd.f64(double %23, double 8.000000e+00, double %25)
%27 = fptrunc double %26 to float
store float %27, float* %3
%28 = load i32, i32* %2
%29 = sub nsw i32 %28, 750000
%30 = load i32, i32* %2
%31 = sub nsw i32 %30, %29
store i32 %31, i32* %2
br label %32
32: ; preds = %19, %10
%33 = load i32, i32* %2
%34 = icmp sgt i32 %33, 600000
br i1 %34, label %35, label %48
35: ; preds = %32
%36 = load i32, i32* %2
%37 = sub nsw i32 %36, 600000
%38 = sitofp i32 %37 to double
%39 = fdiv double %38, 1.000000e+02
%40 = load float, float* %3
%41 = fpext float %40 to double
%42 = call double @llvm.fmuladd.f64(double %39, double 6.000000e+00, double %41)
%43 = fptrunc double %42 to float
store float %43, float* %3
%44 = load i32, i32* %2
%45 = sub nsw i32 %44, 600000
%46 = load i32, i32* %2
%47 = sub nsw i32 %46, %45
store i32 %47, i32* %2
br label %48
48: ; preds = %35, %32
%49 = load i32, i32* %2
%50 = icmp sgt i32 %49, 450000
br i1 %50, label %51, label %64
51: ; preds = %48
%52 = load i32, i32* %2
%53 = sub nsw i32 %52, 450000
%54 = sitofp i32 %53 to double
%55 = fdiv double %54, 1.000000e+02
%56 = load float, float* %3
%57 = fpext float %56 to double
%58 = call double @llvm.fmuladd.f64(double %55, double 4.000000e+00, double %57)
%59 = fptrunc double %58 to float
store float %59, float* %3
%60 = load i32, i32* %2
%61 = sub nsw i32 %60, 450000
%62 = load i32, i32* %2
%63 = sub nsw i32 %62, %61
store i32 %63, i32* %2
br label %64
64: ; preds = %51, %48
%65 = load i32, i32* %2
%66 = icmp sle i32 %65, 450000
br i1 %66, label %67, label %74
67: ; preds = %64
%68 = load i32, i32* %2
%69 = sdiv i32 %68, 100
%70 = mul nsw i32 %69, 2
%71 = sitofp i32 %70 to float
%72 = load float, float* %3
%73 = fadd float %72, %71
store float %73, float* %3
br label %74
74: ; preds = %67, %64
%75 = load float, float* %3
%76 = fpext float %75 to double
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %76)
%78 = load i8*, i8** %4
%79 = call i32 @free(i8* %78)
store i8* null, i8** %4
store i32 0, i32* %1
br label %80
80: ; preds = %74, %8
%81 = load i32, i32* %1
ret i32 %81
}

LLVM IR (-O2):
@.str = [14 x i8] c"Out of memory\00"
@.str.1 = [45 x i8] c"Mata in taxeringsv\C3\A4rdet p\C3\A5 din fastighet: \00"
@stdin = global i32 0
@.str.2 = [30 x i8] c"Du borde betala %.0f i skatt\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %49
5: ; preds = %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = tail call i32 @fgets(i8* %1, i32 8, i32 %7)
%9 = tail call i32 @atoi(i8* %1)
%10 = icmp sgt i32 %9, 750000
br i1 %10, label %11, label %18
11: ; preds = %5
%12 = add nsw i32 %9, -750000
%13 = sitofp i32 %12 to double
%14 = fdiv double %13, 1.000000e+02
%15 = tail call double @llvm.fmuladd.f64(double %14, double 8.000000e+00, double 0.000000e+00)
%16 = fptrunc double %15 to float
%17 = fpext float %16 to double
br label %20
18: ; preds = %5
%19 = icmp sgt i32 %9, 600000
br i1 %19, label %20, label %29
20: ; preds = %18, %11
%21 = phi double [ %17, %11 ], [ 0.000000e+00, %18 ]
%22 = phi i32 [ 750000, %11 ], [ %9, %18 ]
%23 = add nsw i32 %22, -600000
%24 = sitofp i32 %23 to double
%25 = fdiv double %24, 1.000000e+02
%26 = tail call double @llvm.fmuladd.f64(double %25, double 6.000000e+00, double %21)
%27 = fptrunc double %26 to float
%28 = fpext float %27 to double
br label %31
29: ; preds = %18
%30 = icmp sgt i32 %9, 450000
br i1 %30, label %31, label %39
31: ; preds = %20, %29
%32 = phi double [ %28, %20 ], [ 0.000000e+00, %29 ]
%33 = phi i32 [ 600000, %20 ], [ %9, %29 ]
%34 = add nsw i32 %33, -450000
%35 = sitofp i32 %34 to double
%36 = fdiv double %35, 1.000000e+02
%37 = tail call double @llvm.fmuladd.f64(double %36, double 4.000000e+00, double %32)
%38 = fptrunc double %37 to float
br label %39
39: ; preds = %31, %29
%40 = phi i32 [ 450000, %31 ], [ %9, %29 ]
%41 = phi float [ %38, %31 ], [ 0.000000e+00, %29 ]
%42 = sdiv i32 %40, 100
%43 = shl nsw i32 %42, 1
%44 = sitofp i32 %43 to float
%45 = fadd float %41, %44
%46 = fpext float %45 to double
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %46)
%48 = tail call i32 @free(i8* %1)
br label %49
49: ; preds = %39, %3
%50 = phi i32 [ 1, %3 ], [ 0, %39 ]
ret i32 %50
}