#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*/ free(char *);
char **str_array_clear(char **arr, int size) {
  int i;
  for (i = 0; i < size; i++) {
    if (arr[i] != NULL) {
      free(arr[i]);
      arr[i] = NULL;
    }
  }
}


x86 assembly (clang, -O0):
<str_array_clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1179 <str_array_clear+0x69>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1166 <str_array_clear+0x56>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
jmp    116b <str_array_clear+0x5b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <str_array_clear+0x16>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_array_clear>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
jle    1151 <str_array_clear+0x41>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
jmp    1139 <str_array_clear+0x29>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r14
je     1151 <str_array_clear+0x41>
mov    (%r15,%rbx,8),%rdi
test   %rdi,%rdi
je     1130 <str_array_clear+0x20>
call   1030 <free@plt>
movq   $0x0,(%r15,%rbx,8)
jmp    1130 <str_array_clear+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define noalias i8** @str_array_clear(i8** nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %13
%7 = phi i64 [ 0, %4 ], [ %14, %13 ]
%8 = getelementptr inbounds i8*, i8** %0, i64 %7
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 @free(i8* %9)
store i8* null, i8** %8
br label %13
13: ; preds = %6, %11
%14 = add nuw nsw i64 %7, 1
%15 = icmp eq i64 %14, %5
br i1 %15, label %16, label %6
16: ; preds = %13, %2
ret i8** undef
}