#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 amf_su {
  int dummy;
};
typedef struct amf_si_assignment amf_si_assignment;

/* Variables and functions */
struct amf_si_assignment *
amf_su_get_next_si_assignment(struct amf_su *, struct amf_si_assignment *);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
void amf_su_foreach_si_assignment(
    struct amf_su *su,
    void (*foreach_fn)(struct amf_su *su,
                       struct amf_si_assignment *si_assignment)) {
  struct amf_si_assignment *si_assignment;
  assert(foreach_fn != NULL);
  si_assignment = amf_su_get_next_si_assignment(su, NULL);
  while (si_assignment != NULL) {
    foreach_fn(su, si_assignment);
    si_assignment = amf_su_get_next_si_assignment(su, si_assignment);
  }
}


x86 assembly (clang, -O0):
<amf_su_foreach_si_assignment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <amf_su_get_next_si_assignment@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1182 <amf_su_foreach_si_assignment+0x62>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   *%rax
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <amf_su_get_next_si_assignment@plt>
mov    %rax,-0x18(%rbp)
jmp    1153 <amf_su_foreach_si_assignment+0x33>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<amf_su_foreach_si_assignment>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1030 <assert@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <amf_su_get_next_si_assignment@plt>
test   %rax,%rax
je     116c <amf_su_foreach_si_assignment+0x4c>
mov    %rax,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <amf_su_get_next_si_assignment@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1150 <amf_su_foreach_si_assignment+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.amf_su = type { i32 }
%struct.amf_si_assignment = type opaque
define void @amf_su_foreach_si_assignment(%struct.amf_su* %0, void (%struct.amf_su*, %struct.amf_si_assignment*)* %1) {
%3 = alloca %struct.amf_su*
%4 = alloca void (%struct.amf_su*, %struct.amf_si_assignment*)*
%5 = alloca %struct.amf_si_assignment*
store %struct.amf_su* %0, %struct.amf_su** %3
store void (%struct.amf_su*, %struct.amf_si_assignment*)* %1, void (%struct.amf_su*, %struct.amf_si_assignment*)** %4
%6 = load void (%struct.amf_su*, %struct.amf_si_assignment*)*, void (%struct.amf_su*, %struct.amf_si_assignment*)** %4
%7 = icmp ne void (%struct.amf_su*, %struct.amf_si_assignment*)* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load %struct.amf_su*, %struct.amf_su** %3
%11 = call %struct.amf_si_assignment* @amf_su_get_next_si_assignment(%struct.amf_su* %10, %struct.amf_si_assignment* null)
store %struct.amf_si_assignment* %11, %struct.amf_si_assignment** %5
br label %12
12: ; preds = %15, %2
%13 = load %struct.amf_si_assignment*, %struct.amf_si_assignment** %5
%14 = icmp ne %struct.amf_si_assignment* %13, null
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load void (%struct.amf_su*, %struct.amf_si_assignment*)*, void (%struct.amf_su*, %struct.amf_si_assignment*)** %4
%17 = load %struct.amf_su*, %struct.amf_su** %3
%18 = load %struct.amf_si_assignment*, %struct.amf_si_assignment** %5
%19 = load %struct.amf_su*, %struct.amf_su** %3
%20 = load %struct.amf_si_assignment*, %struct.amf_si_assignment** %5
%21 = call %struct.amf_si_assignment* @amf_su_get_next_si_assignment(%struct.amf_su* %19, %struct.amf_si_assignment* %20)
store %struct.amf_si_assignment* %21, %struct.amf_si_assignment** %5
br label %12
22: ; preds = %12
ret void
}

LLVM IR (-O2):
%struct.amf_su = type { i32 }
%struct.amf_si_assignment = type opaque
define void @amf_su_foreach_si_assignment(%struct.amf_su* %0, void (%struct.amf_su*, %struct.amf_si_assignment*)* %1) {
%3 = icmp ne void (%struct.amf_su*, %struct.amf_si_assignment*)* %1, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call %struct.amf_si_assignment* @amf_su_get_next_si_assignment(%struct.amf_su* %0, %struct.amf_si_assignment* null)
%7 = icmp eq %struct.amf_si_assignment* %6, null
br i1 %7, label %12, label %8
8: ; preds = %2, %8
%9 = phi %struct.amf_si_assignment* [ %10, %8 ], [ %6, %2 ]
tail call void %1(%struct.amf_su* %0, %struct.amf_si_assignment* %9)
%10 = tail call %struct.amf_si_assignment* @amf_su_get_next_si_assignment(%struct.amf_su* %0, %struct.amf_si_assignment* %9)
%11 = icmp eq %struct.amf_si_assignment* %10, null
br i1 %11, label %12, label %8
12: ; preds = %8, %2
ret void
}