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

/* Variables and functions */
int insmod(struct kmod_ctx *, char *, int /*<<< orphan*/ *);
int insmod_all(struct kmod_ctx *ctx, char **args, int nargs) {
  int i, err = 0;
  for (i = 0; i < nargs; i++) {
    int r = insmod(ctx, args[i], NULL);
    if (r < 0)
      err = r;
  }
  return err;
}


x86 assembly (clang, -O0):
<insmod_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    117c <insmod_all+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <insmod@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1169 <insmod_all+0x59>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <insmod_all+0x5e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1131 <insmod_all+0x21>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insmod_all>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    114e <insmod_all+0x3e>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
xor    %edx,%edx
call   1030 <insmod@plt>
test   %eax,%eax
cmovs  %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <insmod_all+0x20>
jmp    1150 <insmod_all+0x40>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.kmod_ctx = type { i32 }
define i32 @insmod_all(%struct.kmod_ctx* %0, i8** nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %17
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %15, %7 ]
%9 = phi i32 [ 0, %5 ], [ %14, %7 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %8
%11 = load i8*, i8** %10
%12 = tail call i32 @insmod(%struct.kmod_ctx* %0, i8* %11, i32* null)
%13 = icmp slt i32 %12, 0
%14 = select i1 %13, i32 %12, i32 %9
%15 = add nuw nsw i64 %8, 1
%16 = icmp eq i64 %15, %6
br i1 %16, label %17, label %7
17: ; preds = %7, %3
%18 = phi i32 [ 0, %3 ], [ %14, %7 ]
ret i32 %18
}