#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int step_limit(int argc, char **argv) {
  int i;
  for (i = 0; i < argc; i++) {
    if (!strcmp(argv[i], "-l")) {
      if (argc > i + 1) {
        return (int)strtol(argv[i + 1], NULL, 0);
      } else {
        fprintf(stderr, "Must give step limit with -l\n");
        exit(1);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<step_limit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ea <step_limit+0xaa>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11d7 <step_limit+0x97>
mov    -0x8(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jle    11b8 <step_limit+0x78>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x4(%rbp)
jmp    11f1 <step_limit+0xb1>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11dc <step_limit+0x9c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <step_limit+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<step_limit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %edi,%edi
jle    11ab <step_limit+0x6b>
mov    %rsi,%r13
mov    %edi,%r15d
mov    %edi,%ebx
neg    %rbx
mov    $0x1,%ebp
lea    0xe97(%rip),%r12
nopl   0x0(%rax)
mov    -0x8(%r13,%rbp,8),%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1195 <step_limit+0x55>
lea    (%rbx,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbp
cmp    $0x1,%rax
jne    1170 <step_limit+0x30>
jmp    11ab <step_limit+0x6b>
cmp    %r15d,%ebp
jge    11bd <step_limit+0x7d>
mov    0x0(%r13,%rbp,8),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %rax,%r14
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe36(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"-l\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Must give step limit with -l\0A\00"
define i32 @step_limit(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %29
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %26
%7 = phi i64 [ 0, %4 ], [ %27, %26 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %6
%13 = trunc i64 %7 to i32
%14 = add nuw nsw i32 %13, 1
%15 = icmp slt i32 %14, %0
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = zext i32 %14 to i64
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = tail call i64 @strtol(i8* nocapture %19, i32* null, i32 0)
%21 = trunc i64 %20 to i32
br label %29
22: ; preds = %12
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %6
%27 = add nuw nsw i64 %7, 1
%28 = icmp eq i64 %27, %5
br i1 %28, label %29, label %6
29: ; preds = %26, %2, %16
%30 = phi i32 [ %21, %16 ], [ 0, %2 ], [ 0, %26 ]
ret i32 %30
}