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

/* Variables and functions */
int /*<<< orphan*/ app_msgarg(struct msgs_array *, char *);
char **argsplit(char *, char **, int *);
int /*<<< orphan*/ free(char **);
void argsplit_msgarg(struct msgs_array *msgs, char *command, char **program) {
  int argp, i;
  char **vec;
  vec = argsplit(command, program, &argp);
  for (i = 0; i < argp; i++) {
    app_msgarg(msgs, vec[i]);
  }
  free(vec);
}


x86 assembly (clang, -O0):
<argsplit_msgarg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <argsplit@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    118f <argsplit_msgarg+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <app_msgarg@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1160 <argsplit_msgarg+0x30>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argsplit_msgarg>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xc(%rsp),%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rax,%rdx
call   1040 <argsplit@plt>
mov    %rax,%r15
cmpl   $0x0,0xc(%rsp)
jle    117a <argsplit_msgarg+0x4a>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rsi
mov    %r14,%rdi
call   1050 <app_msgarg@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1160 <argsplit_msgarg+0x30>
mov    %r15,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.msgs_array = type { i32 }
define void @argsplit_msgarg(%struct.msgs_array* %0, i8* %1, i8** %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i8** @argsplit(i8* %1, i8** %2, i32* %4)
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %3, %9
%10 = phi i64 [ %14, %9 ], [ 0, %3 ]
%11 = getelementptr inbounds i8*, i8** %6, i64 %10
%12 = load i8*, i8** %11
%13 = call i32 @app_msgarg(%struct.msgs_array* %0, i8* %12)
%14 = add nuw nsw i64 %10, 1
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %9, label %18
18: ; preds = %9, %3
%19 = call i32 @free(i8** %6)
ret void
}