#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*/ fprintf(int /*<<< orphan*/, char *, int);
scalar_t__ openChan(int, char *);
int /*<<< orphan*/ stderr;
int getArgs(int argc, char *argv[]) {
  int i, openfail = 0;
  char *openstr = NULL;
  for (i = 1; i < argc; i++) {
    if (argv[i][0] != '-') {
      openfail += openChan(i, argv[i]);
    }
  }
  if (openfail) {
    fprintf(stderr, "Grandios error, %d open failure(s).\n", openfail);
  }
  return 0;
}


x86 assembly (clang, -O0):
<getArgs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    119d <getArgs+0x7d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     118a <getArgs+0x6a>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <openChan@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
jmp    118f <getArgs+0x6f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1145 <getArgs+0x25>
cmpl   $0x0,-0x18(%rbp)
je     11bf <getArgs+0x9f>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xe46(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getArgs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     117b <getArgs+0x5b>
mov    %rsi,%r15
mov    %edi,%ebx
xor    %r14d,%r14d
mov    $0x1,%ebp
jmp    1149 <getArgs+0x29>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     115e <getArgs+0x3e>
mov    (%r15,%rbp,8),%rsi
cmpb   $0x2d,(%rsi)
je     1140 <getArgs+0x20>
mov    %ebp,%edi
call   1030 <openChan@plt>
add    %eax,%r14d
jmp    1140 <getArgs+0x20>
test   %r14d,%r14d
je     117b <getArgs+0x5b>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
mov    %r14d,%edx
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"Grandios error, %d open failure(s).\0A\00"
define i32 @getArgs(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %6
store i8* null, i8** %7
store i32 1, i32* %5
br label %8
8: ; preds = %35, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %38
12: ; preds = %8
%13 = load i8**, i8*** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 45
br i1 %21, label %22, label %34
22: ; preds = %12
%23 = load i32, i32* %5
%24 = load i8**, i8*** %4
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @openChan(i32 %23, i8* %28)
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = add nsw i64 %31, %29
%33 = trunc i64 %32 to i32
store i32 %33, i32* %6
br label %34
34: ; preds = %22, %12
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %8
38: ; preds = %8
%39 = load i32, i32* %6
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = load i32, i32* %6
%44 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %41, %38
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"Grandios error, %d open failure(s).\0A\00"
define i32 @getArgs(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %27
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %18
%7 = phi i64 [ 1, %4 ], [ %20, %18 ]
%8 = phi i32 [ 0, %4 ], [ %19, %18 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %7
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 45
br i1 %12, label %18, label %13
13: ; preds = %6
%14 = trunc i64 %7 to i32
%15 = tail call i64 @openChan(i32 %14, i8* %10)
%16 = trunc i64 %15 to i32
%17 = add i32 %8, %16
br label %18
18: ; preds = %6, %13
%19 = phi i32 [ %17, %13 ], [ %8, %6 ]
%20 = add nuw nsw i64 %7, 1
%21 = icmp eq i64 %20, %5
br i1 %21, label %22, label %6
22: ; preds = %18
%23 = icmp eq i32 %19, 0
br i1 %23, label %27, label %24
24: ; preds = %22
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %27
27: ; preds = %2, %24, %22
ret i32 0
}