#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 Sfile_destroy_argv(int *argc, char ***argv, int flag) {
  int i;
  if (*argc > 0 && *argv != NULL) {
    for (i = 0; i < *argc; i++) {
      if ((*argv)[i] != NULL)
        free((*argv)[i]);
    }
    free((char *)*argv);
  }
  *argc = 0;
  *argv = NULL;
  return (1);
}


x86 assembly (clang, -O0):
<Sfile_destroy_argv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jle    119d <Sfile_destroy_argv+0x8d>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     119d <Sfile_destroy_argv+0x8d>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    1191 <Sfile_destroy_argv+0x81>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     117e <Sfile_destroy_argv+0x6e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    1183 <Sfile_destroy_argv+0x73>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1145 <Sfile_destroy_argv+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Sfile_destroy_argv>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rdi),%eax
test   %eax,%eax
jle    115b <Sfile_destroy_argv+0x4b>
mov    (%r15),%rcx
test   %rcx,%rcx
je     115b <Sfile_destroy_argv+0x4b>
mov    $0x1,%ebx
xchg   %ax,%ax
mov    -0x8(%rcx,%rbx,8),%rdi
test   %rdi,%rdi
je     1142 <Sfile_destroy_argv+0x32>
call   1030 <free@plt>
mov    (%r14),%eax
movslq %eax,%rcx
cmp    %rcx,%rbx
jge    1153 <Sfile_destroy_argv+0x43>
mov    (%r15),%rcx
add    $0x1,%rbx
jmp    1130 <Sfile_destroy_argv+0x20>
mov    (%r15),%rdi
call   1030 <free@plt>
movl   $0x0,(%r14)
movq   $0x0,(%r15)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @Sfile_destroy_argv(i32* nocapture %0, i8*** nocapture %1, i32 %2) {
%4 = load i32, i32* %0
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %30
6: ; preds = %3
%7 = load i8**, i8*** %1
%8 = icmp eq i8** %7, null
br i1 %8, label %30, label %9
9: ; preds = %6, %24
%10 = phi i32 [ %20, %24 ], [ %4, %6 ]
%11 = phi i8** [ %25, %24 ], [ %7, %6 ]
%12 = phi i64 [ %21, %24 ], [ 0, %6 ]
%13 = getelementptr inbounds i8*, i8** %11, i64 %12
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %19, label %16
16: ; preds = %9
%17 = tail call i32 @free(i8* %14)
%18 = load i32, i32* %0
br label %19
19: ; preds = %9, %16
%20 = phi i32 [ %10, %9 ], [ %18, %16 ]
%21 = add nuw nsw i64 %12, 1
%22 = sext i32 %20 to i64
%23 = icmp slt i64 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = load i8**, i8*** %1
br label %9
26: ; preds = %19
%27 = bitcast i8*** %1 to i8**
%28 = load i8*, i8** %27
%29 = tail call i32 @free(i8* %28)
br label %30
30: ; preds = %26, %6, %3
store i32 0, i32* %0
store i8** null, i8*** %1
ret i32 1
}