#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 ic_token_list {
  int dummy;
};
struct ic_token {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
struct ic_token *ic_token_list_get(struct ic_token_list *, unsigned int);
unsigned int ic_token_list_length(struct ic_token_list *);
int /*<<< orphan*/ ic_token_print(int /*<<< orphan*/ *, struct ic_token *);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ puts(char *);
void ic_token_list_print(FILE *fd, struct ic_token_list *list) {
  struct ic_token *token = 0;
  unsigned int i = 0;
  unsigned int len = 0;
  if (!list) {
    puts("ic_token_list_print: ERROR list was null");
    return;
  }
  len = ic_token_list_length(list);
  for (i = 0; i < len; ++i) {
    token = ic_token_list_get(list, i);
    if (!token) {
      printf(
          "ic_token_list_print: call to ic_token_list_get for i '%d' failed\n",
          i);
      return;
    }
    ic_token_print(fd, token);
  }
}


x86 assembly (clang, -O0):
<ic_token_list_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1192 <ic_token_list_print+0x42>
lea    0xe78(%rip),%rdi
call   1040 <puts@plt>
jmp    11fb <ic_token_list_print+0xab>
mov    -0x10(%rbp),%rdi
call   1050 <ic_token_list_length@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    11fb <ic_token_list_print+0xab>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1070 <ic_token_list_get@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e0 <ic_token_list_print+0x90>
mov    -0x1c(%rbp),%esi
lea    0xe53(%rip),%rdi
call   1060 <printf@plt>
jmp    11fb <ic_token_list_print+0xab>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <ic_token_print@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a5 <ic_token_list_print+0x55>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ic_token_list_print>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     11ad <ic_token_list_print+0x5d>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <ic_token_list_length@plt>
test   %eax,%eax
je     11a2 <ic_token_list_print+0x52>
mov    %eax,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <ic_token_list_get@plt>
test   %rax,%rax
je     11c3 <ic_token_list_print+0x73>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <ic_token_print@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1180 <ic_token_list_print+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe4c(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
lea    0xe5f(%rip),%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <printf@plt>

LLVM IR (-O0):
%struct.ic_token_list = type { i32 }
%struct.ic_token = type { i32 }
@.str = [41 x i8] c"ic_token_list_print: ERROR list was null\00"
@.str.1 = [66 x i8] c"ic_token_list_print: call to ic_token_list_get for i '%d' failed\0A\00"
define void @ic_token_list_print(i32* %0, %struct.ic_token_list* %1) {
%3 = alloca i32*
%4 = alloca %struct.ic_token_list*
%5 = alloca %struct.ic_token*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store %struct.ic_token_list* %1, %struct.ic_token_list** %4
store %struct.ic_token* null, %struct.ic_token** %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load %struct.ic_token_list*, %struct.ic_token_list** %4
%9 = icmp ne %struct.ic_token_list* %8, null
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %35
12: ; preds = %2
%13 = load %struct.ic_token_list*, %struct.ic_token_list** %4
%14 = call i32 @ic_token_list_length(%struct.ic_token_list* %13)
store i32 %14, i32* %7
store i32 0, i32* %6
br label %15
15: ; preds = %32, %12
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = icmp ult i32 %16, %17
br i1 %18, label %19, label %35
19: ; preds = %15
%20 = load %struct.ic_token_list*, %struct.ic_token_list** %4
%21 = load i32, i32* %6
%22 = call %struct.ic_token* @ic_token_list_get(%struct.ic_token_list* %20, i32 %21)
store %struct.ic_token* %22, %struct.ic_token** %5
%23 = load %struct.ic_token*, %struct.ic_token** %5
%24 = icmp ne %struct.ic_token* %23, null
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = load i32, i32* %6
%27 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %35
28: ; preds = %19
%29 = load i32*, i32** %3
%30 = load %struct.ic_token*, %struct.ic_token** %5
%31 = call i32 @ic_token_print(i32* %29, %struct.ic_token* %30)
br label %32
32: ; preds = %28
%33 = load i32, i32* %6
%34 = add i32 %33, 1
store i32 %34, i32* %6
br label %15
35: ; preds = %10, %25, %15
ret void
}

LLVM IR (-O2):
%struct.ic_token_list = type { i32 }
%struct.ic_token = type { i32 }
@.str = [41 x i8] c"ic_token_list_print: ERROR list was null\00"
@.str.1 = [66 x i8] c"ic_token_list_print: call to ic_token_list_get for i '%d' failed\0A\00"
define void @ic_token_list_print(i32* %0, %struct.ic_token_list* %1) {
%3 = icmp eq %struct.ic_token_list* %1, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %19
6: ; preds = %2
%7 = tail call i32 @ic_token_list_length(%struct.ic_token_list* %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %6, %15
%10 = phi i32 [ %17, %15 ], [ 0, %6 ]
%11 = tail call %struct.ic_token* @ic_token_list_get(%struct.ic_token_list* %1, i32 %10)
%12 = icmp eq %struct.ic_token* %11, null
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %19
15: ; preds = %9
%16 = tail call i32 @ic_token_print(i32* %0, %struct.ic_token* %11)
%17 = add nuw i32 %10, 1
%18 = icmp eq i32 %17, %7
br i1 %18, label %19, label %9
19: ; preds = %15, %6, %13, %4
ret void
}