#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 **);
int /*<<< orphan*/ free_string_field(char **);
void free_multiple_field(unsigned int len, void *arg, char ***orig) {
  unsigned int i;
  if (arg) {
    for (i = 0; i < len; ++i) {
      free_string_field(&((*orig)[i]));
    }
    free(arg);
    free(*orig);
    *orig = 0;
  }
}


x86 assembly (clang, -O0):
<free_multiple_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1195 <free_multiple_field+0x75>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1175 <free_multiple_field+0x55>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%eax
shl    $0x3,%rax
add    %rax,%rdi
call   1040 <free_string_field@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <free_multiple_field+0x25>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_multiple_field>:
test   %rsi,%rsi
je     1176 <free_multiple_field+0x56>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
test   %edi,%edi
je     1154 <free_multiple_field+0x34>
mov    %edi,%r12d
shl    $0x3,%r12
xor    %ebx,%ebx
mov    (%r15),%rdi
add    %rbx,%rdi
call   1040 <free_string_field@plt>
add    $0x8,%rbx
cmp    %rbx,%r12
jne    1140 <free_multiple_field+0x20>
mov    %r14,%rdi
call   1030 <free@plt>
mov    (%r15),%rdi
call   1030 <free@plt>
movq   $0x0,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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