#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 DynArr {
  int dummy;
};

/* Variables and functions */
int getDynArr(struct DynArr *, int);
int /*<<< orphan*/ printf(char *, ...);
int sizeDynArr(struct DynArr *);
void printDynArr(struct DynArr *myArr) {
  int i;
  for (i = 0; i < sizeDynArr(myArr); i++) {
    printf("%d, ", getDynArr(myArr, i));
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printDynArr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <sizeDynArr@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    1189 <printDynArr+0x59>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <getDynArr@plt>
mov    %eax,%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <printDynArr+0x13>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printDynArr>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <sizeDynArr@plt>
test   %eax,%eax
jle    1185 <printDynArr+0x45>
lea    0xea9(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <getDynArr@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <sizeDynArr@plt>
cmp    %eax,%ebp
jl     1160 <printDynArr+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.DynArr = type { i32 }
@.str = [5 x i8] c"%d, \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @printDynArr(%struct.DynArr* %0) {
%2 = alloca %struct.DynArr*
%3 = alloca i32
store %struct.DynArr* %0, %struct.DynArr** %2
store i32 0, i32* %3
br label %4
4: ; preds = %14, %1
%5 = load i32, i32* %3
%6 = load %struct.DynArr*, %struct.DynArr** %2
%7 = call i32 @sizeDynArr(%struct.DynArr* %6)
%8 = icmp slt i32 %5, %7
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = load %struct.DynArr*, %struct.DynArr** %2
%11 = load i32, i32* %3
%12 = call i32 @getDynArr(%struct.DynArr* %10, i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %9
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %4
17: ; preds = %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.DynArr = type { i32 }
@.str = [5 x i8] c"%d, \00"
define void @printDynArr(%struct.DynArr* %0) {
%2 = tail call i32 @sizeDynArr(%struct.DynArr* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %11
4: ; preds = %1, %4
%5 = phi i32 [ %8, %4 ], [ 0, %1 ]
%6 = tail call i32 @getDynArr(%struct.DynArr* %0, i32 %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = add nuw nsw i32 %5, 1
%9 = tail call i32 @sizeDynArr(%struct.DynArr* %0)
%10 = icmp slt i32 %8, %9
br i1 %10, label %4, label %11
11: ; preds = %4, %1
%12 = tail call i32 @putchar(i32 10)
ret void
}