#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*/ bottle(float, int, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int brew_beer(float barley, float hops, float water) {
  float vol;
  int *bottles;
  int i, n, nbottles;
  if (water / barley > 10.0) {
    printf("There is less water in the Atlatic...\n");
  } else if (water / barley < 2.5) {
    printf("Are you making porridge?\n");
  }
  if (water / hops > 20.0) {
    printf("Are you kidding me? Budwiser?\n");
  } else if (water / hops < 10.0) {
    printf("Whoa! Feeling bitter?\n");
  }
  nbottles = 22;
  bottles = (int *)malloc((sizeof(float) * nbottles - 1));
  vol = water * 0.9;
  bottle(vol, nbottles, bottles);
  n = 0;
  for (i = 0; i < nbottles; i++) {
    if (bottles[i] == 1)
      n++;
  }
  return n;
}


x86 assembly (clang, -O0):
<brew_beer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
divss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1178 <brew_beer+0x48>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
jmp    11a9 <brew_beer+0x79>
movss  -0xc(%rbp),%xmm0
divss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe7a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a4 <brew_beer+0x74>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    11a9 <brew_beer+0x79>
movss  -0xc(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe51(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11da <brew_beer+0xaa>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
jmp    120b <brew_beer+0xdb>
movss  -0xc(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe10(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1206 <brew_beer+0xd6>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
jmp    120b <brew_beer+0xdb>
movl   $0x16,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
sub    $0x1,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdde(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <bottle@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12a0 <brew_beer+0x170>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    128d <brew_beer+0x15d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1292 <brew_beer+0x162>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1266 <brew_beer+0x136>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<brew_beer>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm2,0xc(%rsp)
divss  %xmm0,%xmm2
ucomiss 0xeba(%rip),%xmm2
jbe    1157 <brew_beer+0x27>
movss  %xmm1,0x8(%rsp)
lea    0xf28(%rip),%rdi
jmp    1171 <brew_beer+0x41>
movss  0xea5(%rip),%xmm0
ucomiss %xmm2,%xmm0
jbe    117c <brew_beer+0x4c>
movss  %xmm1,0x8(%rsp)
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
movss  0x8(%rsp),%xmm1
movss  0xc(%rsp),%xmm0
divss  %xmm1,%xmm0
ucomiss 0xe7b(%rip),%xmm0
jbe    1198 <brew_beer+0x68>
lea    0xeb0(%rip),%rdi
jmp    11ac <brew_beer+0x7c>
movss  0xe60(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11b1 <brew_beer+0x81>
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
mov    $0x57,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe40(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    $0x16,%edi
mov    %rax,%rsi
call   1050 <bottle@plt>
movdqu (%rbx),%xmm2
movdqu 0x10(%rbx),%xmm3
movdqu 0x20(%rbx),%xmm4
movdqu 0x30(%rbx),%xmm5
movdqu 0x40(%rbx),%xmm0
movdqa 0xe1f(%rip),%xmm1
xor    %ecx,%ecx
cmpl   $0x1,0x50(%rbx)
sete   %cl
xor    %edx,%edx
cmpl   $0x1,0x54(%rbx)
sete   %dl
pcmpeqd %xmm1,%xmm5
pcmpeqd %xmm1,%xmm4
packssdw %xmm5,%xmm4
pcmpeqd %xmm1,%xmm3
pcmpeqd %xmm1,%xmm2
packssdw %xmm3,%xmm2
packsswb %xmm4,%xmm2
pmovmskb %xmm2,%eax
mov    %eax,%esi
shr    %esi
and    $0x5555,%esi
sub    %esi,%eax
mov    %eax,%esi
and    $0x3333,%esi
shr    $0x2,%eax
and    $0x3333,%eax
add    %esi,%eax
mov    %eax,%esi
shr    $0x4,%esi
add    %eax,%esi
and    $0xf0f,%esi
mov    %esi,%eax
shl    $0x8,%eax
add    %esi,%eax
movzbl %ah,%esi
pcmpeqd %xmm1,%xmm0
movmskps %xmm0,%eax
mov    %eax,%ebx
shr    %bl
and    $0x5,%bl
sub    %bl,%al
mov    %eax,%ebx
and    $0x33,%bl
shr    $0x2,%al
and    $0x33,%al
add    %bl,%al
mov    %eax,%ebx
shr    $0x4,%bl
add    %al,%bl
and    $0xf,%bl
movzbl %bl,%eax
add    %esi,%eax
add    %ecx,%eax
add    %edx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"There is less water in the Atlatic...\0A\00"
@.str.1 = [26 x i8] c"Are you making porridge?\0A\00"
@.str.2 = [31 x i8] c"Are you kidding me? Budwiser?\0A\00"
@.str.3 = [23 x i8] c"Whoa! Feeling bitter?\0A\00"
define i32 @brew_beer(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%12 = load float, float* %6
%13 = load float, float* %4
%14 = fdiv float %12, %13
%15 = fpext float %14 to double
%16 = fcmp ogt double %15, 1.000000e+01
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %28
19: ; preds = %3
%20 = load float, float* %6
%21 = load float, float* %4
%22 = fdiv float %20, %21
%23 = fpext float %22 to double
%24 = fcmp olt double %23, 2.500000e+00
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %19
br label %28
28: ; preds = %27, %17
%29 = load float, float* %6
%30 = load float, float* %5
%31 = fdiv float %29, %30
%32 = fpext float %31 to double
%33 = fcmp ogt double %32, 2.000000e+01
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %45
36: ; preds = %28
%37 = load float, float* %6
%38 = load float, float* %5
%39 = fdiv float %37, %38
%40 = fpext float %39 to double
%41 = fcmp olt double %40, 1.000000e+01
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %42, %36
br label %45
45: ; preds = %44, %34
store i32 22, i32* %11
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = mul i64 4, %47
%49 = sub i64 %48, 1
%50 = trunc i64 %49 to i32
%51 = call i64 @malloc(i32 %50)
%52 = inttoptr i64 %51 to i32*
store i32* %52, i32** %8
%53 = load float, float* %6
%54 = fpext float %53 to double
%55 = fmul double %54, 9.000000e-01
%56 = fptrunc double %55 to float
store float %56, float* %7
%57 = load float, float* %7
%58 = load i32, i32* %11
%59 = load i32*, i32** %8
%60 = call i32 @bottle(float %57, i32 %58, i32* %59)
store i32 0, i32* %10
store i32 0, i32* %9
br label %61
61: ; preds = %76, %45
%62 = load i32, i32* %9
%63 = load i32, i32* %11
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %79
65: ; preds = %61
%66 = load i32*, i32** %8
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %66, i64 %68
%70 = load i32, i32* %69
%71 = icmp eq i32 %70, 1
br i1 %71, label %72, label %75
72: ; preds = %65
%73 = load i32, i32* %10
%74 = add nsw i32 %73, 1
store i32 %74, i32* %10
br label %75
75: ; preds = %72, %65
br label %76
76: ; preds = %75
%77 = load i32, i32* %9
%78 = add nsw i32 %77, 1
store i32 %78, i32* %9
br label %61
79: ; preds = %61
%80 = load i32, i32* %10
ret i32 %80
}

LLVM IR (-O2):
@str = [22 x i8] c"Whoa! Feeling bitter?\00"
@str.4 = [30 x i8] c"Are you kidding me? Budwiser?\00"
@str.5 = [25 x i8] c"Are you making porridge?\00"
@str.6 = [38 x i8] c"There is less water in the Atlatic...\00"
define i32 @brew_beer(float %0, float %1, float %2) {
%4 = fdiv float %2, %0
%5 = fcmp ogt float %4, 1.000000e+01
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = fcmp olt float %4, 2.500000e+00
br i1 %7, label %8, label %11
8: ; preds = %6, %3
%9 = phi i8* [ getelementptr inbounds ([38 x i8], [38 x i8]* @str.6, i64 0, i64 0), %3 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0), %6 ]
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %8, %6
%12 = fdiv float %2, %1
%13 = fcmp ogt float %12, 2.000000e+01
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = fcmp olt float %12, 1.000000e+01
br i1 %15, label %16, label %19
16: ; preds = %14, %11
%17 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0), %11 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0), %14 ]
%18 = tail call i32 @puts(i8* dereferenceable(1) %17)
br label %19
19: ; preds = %16, %14
%20 = tail call i64 @malloc(i32 87)
%21 = inttoptr i64 %20 to i32*
%22 = fpext float %2 to double
%23 = fmul double %22, 9.000000e-01
%24 = fptrunc double %23 to float
%25 = tail call i32 @bottle(float %24, i32 22, i32* %21)
%26 = inttoptr i64 %20 to <16 x i32>*
%27 = load <16 x i32>, <16 x i32>* %26
%28 = icmp eq <16 x i32> %27, <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
%29 = getelementptr inbounds i32, i32* %21, i64 16
%30 = bitcast i32* %29 to <4 x i32>*
%31 = load <4 x i32>, <4 x i32>* %30
%32 = icmp eq <4 x i32> %31, <i32 1, i32 1, i32 1, i32 1>
%33 = getelementptr inbounds i32, i32* %21, i64 20
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 1
%36 = zext i1 %35 to i32
%37 = getelementptr inbounds i32, i32* %21, i64 21
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 1
%40 = zext i1 %39 to i32
%41 = bitcast <16 x i1> %28 to i16
%42 = call i16 @llvm.ctpop.i16(i16 %41)
%43 = zext i16 %42 to i32
%44 = bitcast <4 x i1> %32 to i4
%45 = call i4 @llvm.ctpop.i4(i4 %44)
%46 = zext i4 %45 to i32
%47 = add nuw nsw i32 %43, %46
%48 = add nuw nsw i32 %47, %36
%49 = add nuw nsw i32 %48, %40
ret i32 %49
}