#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*/ perhaps_free_something();
void f2(int *p, int a, int b, int *cond, int *cond2) {
  int i;
  *p = a;
  for (i = 0; cond[i]; i++) {
    if (cond2[i])
      *p = b;
    perhaps_free_something();
  }
}


x86 assembly (clang, -O0):
<f2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     117c <f2+0x6c>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1167 <f2+0x57>
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1030 <perhaps_free_something@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113a <f2+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,(%rdi)
cmpl   $0x0,(%rcx)
je     114f <f2+0x3f>
mov    %r8,%r14
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %rdi,%r12
xor    %ebp,%ebp
jmp    1142 <f2+0x32>
nop
xor    %eax,%eax
call   1030 <perhaps_free_something@plt>
cmpl   $0x0,0x4(%rbx,%rbp,1)
lea    0x4(%rbp),%rbp
je     114f <f2+0x3f>
cmpl   $0x0,(%r14,%rbp,1)
je     1130 <f2+0x20>
mov    %r15d,(%r12)
jmp    1130 <f2+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @f2(i32* %0, i32 %1, i32 %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%12 = load i32, i32* %7
%13 = load i32*, i32** %6
store i32 %12, i32* %13
store i32 0, i32* %11
br label %14
14: ; preds = %33, %5
%15 = load i32*, i32** %9
%16 = load i32, i32* %11
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %36
21: ; preds = %14
%22 = load i32*, i32** %10
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %21
%29 = load i32, i32* %8
%30 = load i32*, i32** %6
store i32 %29, i32* %30
br label %31
31: ; preds = %28, %21
%32 = call i32 (...) @perhaps_free_something()
br label %33
33: ; preds = %31
%34 = load i32, i32* %11
%35 = add nsw i32 %34, 1
store i32 %35, i32* %11
br label %14
36: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @f2(i32* nocapture writeonly %0, i32 %1, i32 %2, i32* nocapture %3, i32* nocapture %4) {
store i32 %1, i32* %0
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %5, %14
%9 = phi i64 [ %16, %14 ], [ 0, %5 ]
%10 = getelementptr inbounds i32, i32* %4, i64 %9
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %8
store i32 %2, i32* %0
br label %14
14: ; preds = %13, %8
%15 = tail call i32 (...) @perhaps_free_something()
%16 = add nuw i64 %9, 1
%17 = getelementptr inbounds i32, i32* %3, i64 %16
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %8
20: ; preds = %14, %5
ret void
}