#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 */
struct ex_block {
  int dummy;
};

/* Variables and functions */
int ex_get_block_param(int, struct ex_block *);
int ex_get_block_params(int exoid, size_t block_count,
                        struct ex_block **blocks) {
  size_t i;
  for (i = 0; i < block_count; i++) {
    int status = ex_get_block_param(exoid, blocks[i]);
    if (status != 0) {
      return status;
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<ex_get_block_params>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    117b <ex_get_block_params+0x6b>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <ex_get_block_param@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1165 <ex_get_block_params+0x55>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1182 <ex_get_block_params+0x72>
jmp    116a <ex_get_block_params+0x5a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112b <ex_get_block_params+0x1b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex_get_block_params>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     1149 <ex_get_block_params+0x39>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%r15d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbp,8),%rsi
mov    %r15d,%edi
call   1030 <ex_get_block_param@plt>
test   %eax,%eax
jne    114b <ex_get_block_params+0x3b>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <ex_get_block_params+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ex_block = type { i32 }
define i32 @ex_get_block_params(i32 %0, i64 %1, %struct.ex_block** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca %struct.ex_block**
%8 = alloca i64
%9 = alloca i32
store i32 %0, i32* %5
store i64 %1, i64* %6
store %struct.ex_block** %2, %struct.ex_block*** %7
store i64 0, i64* %8
br label %10
10: ; preds = %26, %3
%11 = load i64, i64* %8
%12 = load i64, i64* %6
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i32, i32* %5
%16 = load %struct.ex_block**, %struct.ex_block*** %7
%17 = load i64, i64* %8
%18 = getelementptr inbounds %struct.ex_block*, %struct.ex_block** %16, i64 %17
%19 = load %struct.ex_block*, %struct.ex_block** %18
%20 = call i32 @ex_get_block_param(i32 %15, %struct.ex_block* %19)
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %14
%24 = load i32, i32* %9
store i32 %24, i32* %4
br label %30
25: ; preds = %14
br label %26
26: ; preds = %25
%27 = load i64, i64* %8
%28 = add i64 %27, 1
store i64 %28, i64* %8
br label %10
29: ; preds = %10
store i32 0, i32* %4
br label %30
30: ; preds = %29, %23
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
%struct.ex_block = type { i32 }
define i32 @ex_get_block_params(i32 %0, i64 %1, %struct.ex_block** nocapture %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %14, label %7
5: ; preds = %7
%6 = icmp eq i64 %13, %1
br i1 %6, label %14, label %7
7: ; preds = %3, %5
%8 = phi i64 [ %13, %5 ], [ 0, %3 ]
%9 = getelementptr inbounds %struct.ex_block*, %struct.ex_block** %2, i64 %8
%10 = load %struct.ex_block*, %struct.ex_block** %9
%11 = tail call i32 @ex_get_block_param(i32 %0, %struct.ex_block* %10)
%12 = icmp eq i32 %11, 0
%13 = add nuw i64 %8, 1
br i1 %12, label %5, label %14
14: ; preds = %7, %5, %3
%15 = phi i32 [ 0, %3 ], [ 0, %5 ], [ %11, %7 ]
ret i32 %15
}