#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 */
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ test_get_pid_smaps(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc > 1) {
    int i;
    for (i = 1; i < argc; i++) {
      pid_t pid = (pid_t)atoi(argv[1]);
      test_get_pid_smaps(pid);
    }
    return 0;
  }
  test_get_pid_smaps(getpid());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1195 <main+0x65>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1189 <main+0x59>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <test_get_pid_smaps@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <main+0x27>
movl   $0x0,-0x4(%rbp)
jmp    11aa <main+0x7a>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
call   1040 <test_get_pid_smaps@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1157 <main+0x27>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0xffffffff,%ebp
mov    0x8(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%edi
call   1040 <test_get_pid_smaps@plt>
add    $0xffffffff,%ebp
jne    1140 <main+0x10>
jmp    1165 <main+0x35>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%edi
call   1040 <test_get_pid_smaps@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
br label %6
6: ; preds = %4, %6
%7 = phi i32 [ 1, %4 ], [ %11, %6 ]
%8 = load i8*, i8** %5
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call i32 @test_get_pid_smaps(i32 %9)
%11 = add nuw nsw i32 %7, 1
%12 = icmp eq i32 %11, %0
br i1 %12, label %16, label %6
13: ; preds = %2
%14 = tail call i32 (...) @getpid()
%15 = tail call i32 @test_get_pid_smaps(i32 %14)
br label %16
16: ; preds = %6, %13
ret i32 0
}