#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int where_in_command_line(int, char **, char *);
int int_set_from_argv(int argc, char **argv, char *tag, char *stoptag,
                      int *found_list, int *destination, int len) {
  int i, which_argc, nguess, nuse;
  which_argc = where_in_command_line(argc, argv, tag);
  if (which_argc < 1) {
    fprintf(stderr, "Tag %s not found in char_set_from_argv.\n", tag);
    return -1;
  }
  nguess =
      where_in_command_line(argc - which_argc, &argv[which_argc], stoptag) - 1;
  if (nguess < 0)
    nguess = argc - which_argc;
  if (nguess > len) {
    fprintf(stderr,
            "Warning - have %d guess tags in %s, but only space for %d.  "
            "Truncating....\n",
            nguess, tag, len);
    nguess = len;
  }
  found_list[which_argc] = 1;
  for (i = 0; i < nguess; i++) {
    destination[i] = atoi(argv[which_argc + i + 1]);
    found_list[which_argc + i + 1] = 1;
  }
  return nguess;
}


x86 assembly (clang, -O0):
<int_set_from_argv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <where_in_command_line@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x1,-0x38(%rbp)
jge    1196 <int_set_from_argv+0x66>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <int_set_from_argv+0x144>
mov    -0x8(%rbp),%edi
sub    -0x38(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
call   1030 <where_in_command_line@plt>
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    11cd <int_set_from_argv+0x9d>
mov    -0x8(%rbp),%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    0x10(%rbp),%eax
jle    1201 <int_set_from_argv+0xd1>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    0x10(%rbp),%r8d
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x38(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    126e <int_set_from_argv+0x13e>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%edx
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1217 <int_set_from_argv+0xe7>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_set_from_argv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r12
mov    %r8,%rbx
mov    %rcx,0x8(%rsp)
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
call   1030 <where_in_command_line@plt>
test   %eax,%eax
jle    11af <int_set_from_argv+0x7f>
mov    %eax,%r13d
mov    %r12,0x10(%rsp)
mov    %r14,(%rsp)
mov    0x50(%rsp),%r12d
sub    %eax,%ebp
mov    %eax,%eax
mov    %rax,%r14
lea    (%r15,%rax,8),%rsi
mov    %ebp,%edi
mov    0x8(%rsp),%rdx
call   1030 <where_in_command_line@plt>
lea    -0x1(%rax),%edx
test   %eax,%eax
cmovle %ebp,%edx
cmp    %r12d,%edx
jle    11d1 <int_set_from_argv+0xa1>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
mov    (%rsp),%rcx
mov    %r12d,%r8d
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11d4 <int_set_from_argv+0xa4>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%r12d
jmp    1233 <int_set_from_argv+0x103>
mov    %edx,%r12d
movl   $0x1,(%rbx,%r14,4)
test   %r12d,%r12d
jle    1233 <int_set_from_argv+0x103>
mov    %r12d,(%rsp)
mov    %r12d,%eax
mov    %rax,0x8(%rsp)
add    $0x1,%r13d
xor    %ebp,%ebp
mov    %r15,%r12
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%rbp),%r14
lea    0x0(%r13,%rbp,1),%eax
movslq %eax,%r15
mov    (%r12,%r15,8),%rdi
call   1050 <atoi@plt>
mov    0x10(%rsp),%rcx
mov    %eax,(%rcx,%rbp,4)
movl   $0x1,(%rbx,%r15,4)
mov    %r14,%rbp
cmp    %r14,0x8(%rsp)
jne    1200 <int_set_from_argv+0xd0>
mov    (%rsp),%r12d
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"Tag %s not found in char_set_from_argv.\0A\00"
@.str.1 = [76 x i8] c"Warning - have %d guess tags in %s, but only space for %d. Truncating....\0A\00"
define i32 @int_set_from_argv(i32 %0, i8** %1, i8* %2, i8* %3, i32* %4, i32* %5, i32 %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 %0, i32* %9
store i8** %1, i8*** %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i32* %4, i32** %13
store i32* %5, i32** %14
store i32 %6, i32* %15
%20 = load i32, i32* %9
%21 = load i8**, i8*** %10
%22 = load i8*, i8** %11
%23 = call i32 @where_in_command_line(i32 %20, i8** %21, i8* %22)
store i32 %23, i32* %17
%24 = load i32, i32* %17
%25 = icmp slt i32 %24, 1
br i1 %25, label %26, label %30
26: ; preds = %7
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %11
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %28)
store i32 -1, i32* %8
br label %93
30: ; preds = %7
%31 = load i32, i32* %9
%32 = load i32, i32* %17
%33 = sub nsw i32 %31, %32
%34 = load i8**, i8*** %10
%35 = load i32, i32* %17
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %12
%39 = call i32 @where_in_command_line(i32 %33, i8** %37, i8* %38)
%40 = sub nsw i32 %39, 1
store i32 %40, i32* %18
%41 = load i32, i32* %18
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %30
%44 = load i32, i32* %9
%45 = load i32, i32* %17
%46 = sub nsw i32 %44, %45
store i32 %46, i32* %18
br label %47
47: ; preds = %43, %30
%48 = load i32, i32* %18
%49 = load i32, i32* %15
%50 = icmp sgt i32 %48, %49
br i1 %50, label %51, label %58
51: ; preds = %47
%52 = load i32, i32* @stderr
%53 = load i32, i32* %18
%54 = load i8*, i8** %11
%55 = load i32, i32* %15
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0), i32 %53, i8* %54, i32 %55)
%57 = load i32, i32* %15
store i32 %57, i32* %18
br label %58
58: ; preds = %51, %47
%59 = load i32*, i32** %13
%60 = load i32, i32* %17
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
store i32 1, i32* %62
store i32 0, i32* %16
br label %63
63: ; preds = %88, %58
%64 = load i32, i32* %16
%65 = load i32, i32* %18
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %91
67: ; preds = %63
%68 = load i8**, i8*** %10
%69 = load i32, i32* %17
%70 = load i32, i32* %16
%71 = add nsw i32 %69, %70
%72 = add nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %68, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 @atoi(i8* %75)
%77 = load i32*, i32** %14
%78 = load i32, i32* %16
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i32, i32* %77, i64 %79
store i32 %76, i32* %80
%81 = load i32*, i32** %13
%82 = load i32, i32* %17
%83 = load i32, i32* %16
%84 = add nsw i32 %82, %83
%85 = add nsw i32 %84, 1
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* %81, i64 %86
store i32 1, i32* %87
br label %88
88: ; preds = %67
%89 = load i32, i32* %16
%90 = add nsw i32 %89, 1
store i32 %90, i32* %16
br label %63
91: ; preds = %63
%92 = load i32, i32* %18
store i32 %92, i32* %8
br label %93
93: ; preds = %91, %26
%94 = load i32, i32* %8
ret i32 %94
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"Tag %s not found in char_set_from_argv.\0A\00"
@.str.1 = [76 x i8] c"Warning - have %d guess tags in %s, but only space for %d. Truncating....\0A\00"
define i32 @int_set_from_argv(i32 %0, i8** %1, i8* %2, i8* %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, i32 %6) {
%8 = tail call i32 @where_in_command_line(i32 %0, i8** %1, i8* %2)
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %43
13: ; preds = %7
%14 = sub nsw i32 %0, %8
%15 = zext i32 %8 to i64
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = tail call i32 @where_in_command_line(i32 %14, i8** %16, i8* %3)
%18 = add nsw i32 %17, -1
%19 = icmp slt i32 %17, 1
%20 = select i1 %19, i32 %14, i32 %18
%21 = icmp sgt i32 %20, %6
br i1 %21, label %22, label %25
22: ; preds = %13
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0), i32 %20, i8* %2, i32 %6)
br label %25
25: ; preds = %22, %13
%26 = phi i32 [ %6, %22 ], [ %20, %13 ]
%27 = getelementptr inbounds i32, i32* %4, i64 %15
store i32 1, i32* %27
%28 = icmp sgt i32 %26, 0
br i1 %28, label %29, label %43
29: ; preds = %25
%30 = zext i32 %26 to i64
br label %31
31: ; preds = %29, %31
%32 = phi i64 [ 0, %29 ], [ %33, %31 ]
%33 = add nuw nsw i64 %32, 1
%34 = trunc i64 %33 to i32
%35 = add i32 %8, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %1, i64 %36
%38 = load i8*, i8** %37
%39 = tail call i32 @atoi(i8* %38)
%40 = getelementptr inbounds i32, i32* %5, i64 %32
store i32 %39, i32* %40
%41 = getelementptr inbounds i32, i32* %4, i64 %36
store i32 1, i32* %41
%42 = icmp eq i64 %33, %30
br i1 %42, label %43, label %31
43: ; preds = %31, %25, %10
%44 = phi i32 [ -1, %10 ], [ %26, %25 ], [ %26, %31 ]
ret i32 %44
}