#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 */
scalar_t__ posix_memalign(void **, int, int);
int foo(float *p) {
  int res = *p;
  struct {
    void *q1;
    void *q2;
  } q;
  if (posix_memalign(&q.q1, 128, 128 * sizeof(int)) != 0)
    return 0;
  if (posix_memalign(&q.q2, 128, 128 * sizeof(int)) != 0)
    return 0;
  *((int *)q.q1) = 1;
  *((int *)q.q2) = 2;
  return res + *p + *((int *)q.q1) + *((int *)q.q2);
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cvttss2si (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0x80,%esi
mov    $0x200,%edx
call   1030 <posix_memalign@plt>
cmp    $0x0,%rax
je     1150 <foo+0x40>
movl   $0x0,-0x4(%rbp)
jmp    11bd <foo+0xad>
lea    -0x28(%rbp),%rdi
add    $0x8,%rdi
mov    $0x80,%esi
mov    $0x200,%edx
call   1030 <posix_memalign@plt>
cmp    $0x0,%rax
je     117d <foo+0x6d>
movl   $0x0,-0x4(%rbp)
jmp    11bd <foo+0xad>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x2,(%rax)
cvtsi2ssl -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
addss  (%rax),%xmm0
mov    -0x28(%rbp),%rax
cvtsi2ssl (%rax),%xmm1
addss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
cvtsi2ssl (%rax),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
cvttss2si (%rdi),%r14d
mov    %rsp,%rdi
mov    $0x80,%esi
mov    $0x200,%edx
call   1030 <posix_memalign@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1184 <foo+0x74>
lea    0x8(%rsp),%rdi
mov    $0x80,%esi
mov    $0x200,%edx
call   1030 <posix_memalign@plt>
test   %rax,%rax
jne    1184 <foo+0x74>
mov    (%rsp),%rax
movl   $0x1,(%rax)
cvtsi2ss %r14d,%xmm0
mov    0x8(%rsp),%rcx
movl   $0x2,(%rcx)
addss  (%rbx),%xmm0
cvtsi2ssl (%rax),%xmm1
addss  %xmm0,%xmm1
addss  0xe80(%rip),%xmm1
cvttss2si %xmm1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.anon = type { i8*, i8* }
define i32 @foo(float* %0) {
%2 = alloca i32
%3 = alloca float*
%4 = alloca i32
%5 = alloca %struct.anon
store float* %0, float** %3
%6 = load float*, float** %3
%7 = load float, float* %6
%8 = fptosi float %7 to i32
store i32 %8, i32* %4
%9 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%10 = call i64 @posix_memalign(i8** %9, i32 128, i32 512)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 0, i32* %2
br label %43
13: ; preds = %1
%14 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 1
%15 = call i64 @posix_memalign(i8** %14, i32 128, i32 512)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 0, i32* %2
br label %43
18: ; preds = %13
%19 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%20 = load i8*, i8** %19
%21 = bitcast i8* %20 to i32*
store i32 1, i32* %21
%22 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 1
%23 = load i8*, i8** %22
%24 = bitcast i8* %23 to i32*
store i32 2, i32* %24
%25 = load i32, i32* %4
%26 = sitofp i32 %25 to float
%27 = load float*, float** %3
%28 = load float, float* %27
%29 = fadd float %26, %28
%30 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = bitcast i8* %31 to i32*
%33 = load i32, i32* %32
%34 = sitofp i32 %33 to float
%35 = fadd float %29, %34
%36 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 1
%37 = load i8*, i8** %36
%38 = bitcast i8* %37 to i32*
%39 = load i32, i32* %38
%40 = sitofp i32 %39 to float
%41 = fadd float %35, %40
%42 = fptosi float %41 to i32
store i32 %42, i32* %2
br label %43
43: ; preds = %18, %17, %12
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
%struct.anon = type { i8*, i8* }
define i32 @foo(float* nocapture %0) {
%2 = alloca %struct.anon
%3 = load float, float* %0
%4 = fptosi float %3 to i32
%5 = bitcast %struct.anon* %2 to i8*
%6 = getelementptr inbounds %struct.anon, %struct.anon* %2, i64 0, i32 0
%7 = call i64 @posix_memalign(i8** %6, i32 128, i32 512)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %1
%10 = getelementptr inbounds %struct.anon, %struct.anon* %2, i64 0, i32 1
%11 = call i64 @posix_memalign(i8** %10, i32 128, i32 512)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = bitcast %struct.anon* %2 to i32**
%15 = load i32*, i32** %14
store i32 1, i32* %15
%16 = bitcast i8** %10 to i32**
%17 = load i32*, i32** %16
store i32 2, i32* %17
%18 = sitofp i32 %4 to float
%19 = load float, float* %0
%20 = fadd float %19, %18
%21 = load i32, i32* %15
%22 = sitofp i32 %21 to float
%23 = fadd float %20, %22
%24 = fadd float %23, 2.000000e+00
%25 = fptosi float %24 to i32
br label %26
26: ; preds = %9, %1, %13
%27 = phi i32 [ %25, %13 ], [ 0, %1 ], [ 0, %9 ]
ret i32 %27
}