#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*/ exit(int);
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
float strtod(char *, char **);
int main() {
  char input[24];
  char output[24];
  char *r;
  int a, b;
  float winnings;
  printf("Enter your lotto winnings: $");
  r = fgets(input, 24, stdin);
  if (r == NULL) {
    fprintf(stderr, "Null string input\n");
    exit(1);
  }
  a = b = 0;
  while (1) {
    if (input[a] == '\n') {
      output[b] = '\0';
      break;
    }
    if (input[a] == ',') {
      a++;
      continue;
    }
    output[b] = input[a];
    b++;
    a++;
    if (a == 24) {
      output[b] = '\0';
      break;
    }
  }
  winnings = strtod(output, &r);
  if (r == output) {
    fprintf(stderr, "Invalid input\n");
    exit(1);
  }
  if (winnings < 0) {
    puts("Negative winnings aren't taxed");
    exit(0);
  }
  winnings *= 0.55;
  printf("After taxes, that's $%.2f\n", winnings);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    $0x18,%esi
call   1060 <fgets@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11c2 <main+0x62>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x4c(%rbp)
movslq -0x4c(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    11f0 <main+0x90>
movslq -0x50(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
jmp    124f <main+0xef>
movslq -0x4c(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x2c,%eax
jne    1210 <main+0xb0>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11d0 <main+0x70>
movslq -0x4c(%rbp),%rax
mov    -0x20(%rbp,%rax,1),%cl
movslq -0x50(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x18,-0x4c(%rbp)
jne    124a <main+0xea>
movslq -0x50(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
jmp    124f <main+0xef>
jmp    11d0 <main+0x70>
lea    -0x40(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1040 <strtod@plt>
movss  %xmm0,-0x54(%rbp)
mov    -0x48(%rbp),%rax
lea    -0x40(%rbp),%rcx
cmp    %rcx,%rax
jne    1291 <main+0x131>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
xorps  %xmm0,%xmm0
ucomiss -0x54(%rbp),%xmm0
jbe    12b1 <main+0x151>
lea    0xda2(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>
movss  -0x54(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd3e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x54(%rbp)
movss  -0x54(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd87(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
lea    0xe9c(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edx
lea    0x30(%rsp),%rdi
mov    $0x18,%esi
call   1060 <fgets@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1234 <main+0xd4>
xor    %eax,%eax
movslq %ebx,%rcx
lea    0x1(%rcx),%ebx
add    %rsp,%rcx
add    $0x30,%rcx
nopw   0x0(%rax,%rax,1)
movzbl (%rcx),%edx
cmp    $0x2c,%dl
jne    11d0 <main+0x70>
add    $0x1,%ebx
add    $0x1,%rcx
jmp    11b0 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0xa,%dl
je     11e2 <main+0x82>
mov    %dl,0x10(%rsp,%rax,1)
add    $0x1,%rax
cmp    $0x18,%ebx
jne    119d <main+0x3d>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <strtod@plt>
cmp    %rbx,0x8(%rsp)
je     1246 <main+0xe6>
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1265 <main+0x105>
cvtss2sd %xmm0,%xmm0
mulsd  0xdea(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
jmp    1256 <main+0xf6>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xddb(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Enter your lotto winnings: $\00"
@stdin = global i32 0
@stderr = global i32 0
@.str.1 = [19 x i8] c"Null string input\0A\00"
@.str.2 = [15 x i8] c"Invalid input\0A\00"
@.str.3 = [31 x i8] c"Negative winnings aren't taxed\00"
@.str.4 = [27 x i8] c"After taxes, that's $%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [24 x i8]
%3 = alloca [24 x i8]
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i8* @fgets(i8* %9, i32 24, i32 %10)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %0
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %0
store i32 0, i32* %6
store i32 0, i32* %5
br label %19
19: ; preds = %18, %37, %58
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
br label %59
30: ; preds = %19
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 44
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %19
40: ; preds = %30
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 %46
store i8 %44, i8* %47
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
%52 = load i32, i32* %5
%53 = icmp eq i32 %52, 24
br i1 %53, label %54, label %58
54: ; preds = %40
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 %56
store i8 0, i8* %57
br label %59
58: ; preds = %40
br label %19
59: ; preds = %54, %26
%60 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%61 = call float @strtod(i8* %60, i8** %4)
store float %61, float* %7
%62 = load i8*, i8** %4
%63 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%64 = icmp eq i8* %62, %63
br i1 %64, label %65, label %69
65: ; preds = %59
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %59
%70 = load float, float* %7
%71 = fcmp olt float %70, 0.000000e+00
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%74 = call i32 @exit(i32 0)
unreachable
75: ; preds = %69
%76 = load float, float* %7
%77 = fpext float %76 to double
%78 = fmul double %77, 5.500000e-01
%79 = fptrunc double %78 to float
store float %79, float* %7
%80 = load float, float* %7
%81 = fpext float %80 to double
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %81)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Enter your lotto winnings: $\00"
@stdin = global i32 0
@stderr = global i32 0
@.str.1 = [19 x i8] c"Null string input\0A\00"
@.str.2 = [15 x i8] c"Invalid input\0A\00"
@.str.3 = [31 x i8] c"Negative winnings aren't taxed\00"
@.str.4 = [27 x i8] c"After taxes, that's $%.2f\0A\00"
define i32 @main() {
%1 = alloca [24 x i8]
%2 = alloca [24 x i8]
%3 = alloca i8*
%4 = getelementptr inbounds [24 x i8], [24 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%6 = bitcast i8** %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i8* @fgets(i8* %4, i32 24, i32 %8)
store i8* %9, i8** %3
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %27
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %27, %19
%16 = phi i64 [ %30, %27 ], [ %20, %19 ]
%17 = getelementptr inbounds [24 x i8], [24 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
switch i8 %18, label %21 [
i8 10, label %31
i8 44, label %19
]
19: ; preds = %15
%20 = add i64 %16, 1
br label %15
21: ; preds = %15
%22 = trunc i64 %16 to i32
%23 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 %28
store i8 %18, i8* %23
%24 = add nuw i64 %28, 1
%25 = add nsw i32 %22, 1
%26 = icmp eq i32 %25, 24
br i1 %26, label %31, label %27
27: ; preds = %0, %21
%28 = phi i64 [ %24, %21 ], [ 0, %0 ]
%29 = phi i32 [ %25, %21 ], [ 0, %0 ]
%30 = sext i32 %29 to i64
br label %15
31: ; preds = %21, %15
%32 = phi i64 [ %28, %15 ], [ %24, %21 ]
%33 = and i64 %32, 4294967295
%34 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 %33
store i8 0, i8* %34
%35 = call float @strtod(i8* %5, i8** %3)
%36 = load i8*, i8** %3
%37 = icmp eq i8* %36, %5
br i1 %37, label %38, label %42
38: ; preds = %31
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %31
%43 = fcmp olt float %35, 0.000000e+00
br i1 %43, label %44, label %47
44: ; preds = %42
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 @exit(i32 0)
unreachable
47: ; preds = %42
%48 = fpext float %35 to double
%49 = fmul double %48, 5.500000e-01
%50 = fptrunc double %49 to float
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %51)
ret i32 0
}