#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  char name[25], ch;
  int u, i = 0;
  float t = 0;
  printf("Enter the Name of Consumer: ");
  while ((ch = getchar()) != '\n' && i < 25)
    name[i++] = ch;
  printf("Enter the Units Consumed: ");
  scanf("%d", &u);
  if (u < 200)
    t = u * 0.80;
  if (u >= 200 && u < 300)
    t = 200 * 0.80 + (u - 200) * 0.90;
  if (u >= 300)
    t = 200 * 0.80 + 100 * 0.90 + (u - 300);
  if (t > 400)
    t += t * 0.15;
  printf("******************************\n"
         "Name: %-25s \n"
         "Units Consumed: %d\n"
         "AMT: %.2f \n"
         "******************************\n",
         name, u, t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x31(%rbp)
je     1181 <main+0x51>
cmpl   $0x19,-0x2c(%rbp)
setl   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1191 <main+0x61>
jmp    11aa <main+0x7a>
mov    -0x21(%rbp),%cl
mov    -0x2c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
cltq
mov    %cl,-0x20(%rbp,%rax,1)
jmp    115c <main+0x2c>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xc8,-0x28(%rbp)
jge    11ef <main+0xbf>
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  0xe1e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
cmpl   $0xc8,-0x28(%rbp)
jl     1236 <main+0x106>
cmpl   $0x12c,-0x28(%rbp)
jge    1236 <main+0x106>
mov    -0x28(%rbp),%eax
sub    $0xc8,%eax
cvtsi2sd %eax,%xmm0
movsd  0xdeb(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xde7(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
cmpl   $0x12c,-0x28(%rbp)
jl     1264 <main+0x134>
mov    -0x28(%rbp),%eax
sub    $0x12c,%eax
cvtsi2sd %eax,%xmm1
movsd  0xdc1(%rip),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
movss  0xdb7(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    12a5 <main+0x175>
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x30(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xd8c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
lea    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%edx
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdab(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xee8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     116c <main+0x3c>
xor    %ebx,%ebx
mov    %al,0x10(%rsp,%rbx,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     116c <main+0x3c>
lea    0x1(%rbx),%rcx
cmp    $0x18,%rbx
mov    %rcx,%rbx
jb     1150 <main+0x20>
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edx
cmp    $0xc8,%edx
jl     119c <main+0x6c>
xorps  %xmm0,%xmm0
jmp    11ac <main+0x7c>
cvtsi2sd %edx,%xmm0
mulsd  0xe58(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
lea    -0xc8(%rdx),%eax
cmp    $0x64,%eax
jae    11d2 <main+0xa2>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe42(%rip),%xmm0
addsd  0xe42(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cmp    $0x12c,%edx
jl     11e4 <main+0xb4>
lea    -0x32(%rdx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe28(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
movss  0xe19(%rip),%xmm2
cmpltss %xmm0,%xmm2
movaps %xmm2,%xmm3
andnps %xmm0,%xmm3
andps  %xmm1,%xmm2
orps   %xmm3,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe39(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Enter the Name of Consumer: \00"
@.str.1 = [27 x i8] c"Enter the Units Consumed: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [106 x i8] c"******************************\0AName: %-25s \0AUnits Consumed: %d\0AAMT: %.2f \0A******************************\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [25 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %5
store float 0.000000e+00, float* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %17, %0
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 25
br label %15
15: ; preds = %12, %8
%16 = phi i1 [ false, %8 ], [ %14, %12 ]
br i1 %16, label %17, label %23
17: ; preds = %15
%18 = load i8, i8* %3
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 %21
store i8 %18, i8* %22
br label %8
23: ; preds = %15
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 200
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = load i32, i32* %4
%30 = sitofp i32 %29 to double
%31 = fmul double %30, 8.000000e-01
%32 = fptrunc double %31 to float
store float %32, float* %6
br label %33
33: ; preds = %28, %23
%34 = load i32, i32* %4
%35 = icmp sge i32 %34, 200
br i1 %35, label %36, label %45
36: ; preds = %33
%37 = load i32, i32* %4
%38 = icmp slt i32 %37, 300
br i1 %38, label %39, label %45
39: ; preds = %36
%40 = load i32, i32* %4
%41 = sub nsw i32 %40, 200
%42 = sitofp i32 %41 to double
%43 = call double @llvm.fmuladd.f64(double %42, double 9.000000e-01, double 1.600000e+02)
%44 = fptrunc double %43 to float
store float %44, float* %6
br label %45
45: ; preds = %39, %36, %33
%46 = load i32, i32* %4
%47 = icmp sge i32 %46, 300
br i1 %47, label %48, label %54
48: ; preds = %45
%49 = load i32, i32* %4
%50 = sub nsw i32 %49, 300
%51 = sitofp i32 %50 to double
%52 = fadd double 2.500000e+02, %51
%53 = fptrunc double %52 to float
store float %53, float* %6
br label %54
54: ; preds = %48, %45
%55 = load float, float* %6
%56 = fcmp ogt float %55, 4.000000e+02
br i1 %56, label %57, label %64
57: ; preds = %54
%58 = load float, float* %6
%59 = fpext float %58 to double
%60 = load float, float* %6
%61 = fpext float %60 to double
%62 = call double @llvm.fmuladd.f64(double %59, double 1.500000e-01, double %61)
%63 = fptrunc double %62 to float
store float %63, float* %6
br label %64
64: ; preds = %57, %54
%65 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%66 = load i32, i32* %4
%67 = load float, float* %6
%68 = fpext float %67 to double
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.3, i64 0, i64 0), i8* %65, i32 %66, double %68)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Enter the Name of Consumer: \00"
@.str.1 = [27 x i8] c"Enter the Units Consumed: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [106 x i8] c"******************************\0AName: %-25s \0AUnits Consumed: %d\0AAMT: %.2f \0A******************************\0A\00"
define i32 @main() {
%1 = alloca [25 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %17, label %8
8: ; preds = %0, %8
%9 = phi i64 [ %11, %8 ], [ 0, %0 ]
%10 = phi i8 [ %13, %8 ], [ %6, %0 ]
%11 = add nuw nsw i64 %9, 1
%12 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 %9
store i8 %10, i8* %12
%13 = tail call signext i8 (...) @getchar()
%14 = icmp ne i8 %13, 10
%15 = icmp ult i64 %9, 24
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %8, label %17
17: ; preds = %8, %0
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 200
%22 = sitofp i32 %20 to double
%23 = fmul double %22, 8.000000e-01
%24 = fptrunc double %23 to float
%25 = select i1 %21, float %24, float 0.000000e+00
%26 = add i32 %20, -200
%27 = icmp ult i32 %26, 100
%28 = sitofp i32 %26 to double
%29 = call double @llvm.fmuladd.f64(double %28, double 9.000000e-01, double 1.600000e+02)
%30 = fptrunc double %29 to float
%31 = select i1 %27, float %30, float %25
%32 = icmp sgt i32 %20, 299
%33 = add nsw i32 %20, -50
%34 = sitofp i32 %33 to float
%35 = select i1 %32, float %34, float %31
%36 = fcmp ogt float %35, 4.000000e+02
%37 = fpext float %35 to double
%38 = call double @llvm.fmuladd.f64(double %37, double 1.500000e-01, double %37)
%39 = fptrunc double %38 to float
%40 = select i1 %36, float %39, float %35
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([106 x i8], [106 x i8]* @.str.3, i64 0, i64 0), i8* %3, i32 %20, double %41)
ret i32 0
}