#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ print_help();
char *strtok(char *, char *);
void parse_mem(char *optarg, unsigned int *stressmem, unsigned int *maxmem) {
  char *pch;
  pch = strtok(optarg, ",");
  if (pch != NULL) {
    *stressmem = (unsigned int)atoi(pch);
    pch = strtok(NULL, ",");
    if (pch != NULL) {
      *maxmem = (unsigned int)atoi(pch);
    } else {
      *maxmem = *stressmem;
    }
  } else {
    print_help();
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<parse_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ca <parse_mem+0x8a>
mov    -0x20(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe71(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11b9 <parse_mem+0x79>
mov    -0x20(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11c5 <parse_mem+0x85>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11db <parse_mem+0x9b>
mov    $0x0,%al
call   1050 <print_help@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_mem>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0xeaf(%rip),%rsi
call   1030 <strtok@plt>
test   %rax,%rax
je     118f <parse_mem+0x4f>
mov    %rax,%rdi
call   1040 <atoi@plt>
mov    %eax,(%rbx)
lea    0xe94(%rip),%rsi
xor    %edi,%edi
call   1030 <strtok@plt>
test   %rax,%rax
je     1182 <parse_mem+0x42>
mov    %rax,%rdi
call   1040 <atoi@plt>
jmp    1184 <parse_mem+0x44>
mov    (%rbx),%eax
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1050 <print_help@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define void @parse_mem(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i8*, i8** %4
%9 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %30
12: ; preds = %3
%13 = load i8*, i8** %7
%14 = call i64 @atoi(i8* %13)
%15 = trunc i64 %14 to i32
%16 = load i32*, i32** %5
store i32 %15, i32* %16
%17 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %25
20: ; preds = %12
%21 = load i8*, i8** %7
%22 = call i64 @atoi(i8* %21)
%23 = trunc i64 %22 to i32
%24 = load i32*, i32** %6
store i32 %23, i32* %24
br label %29
25: ; preds = %12
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = load i32*, i32** %6
store i32 %27, i32* %28
br label %29
29: ; preds = %25, %20
br label %33
30: ; preds = %3
%31 = call i32 (...) @print_help()
%32 = call i32 @exit(i32 -1)
unreachable
33: ; preds = %29
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define void @parse_mem(i8* %0, i32* nocapture %1, i32* nocapture writeonly %2) {
%4 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i64 @atoi(i8* %4)
%8 = trunc i64 %7 to i32
store i32 %8, i32* %1
%9 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = tail call i64 @atoi(i8* %9)
%13 = trunc i64 %12 to i32
br label %19
14: ; preds = %6
%15 = load i32, i32* %1
br label %19
16: ; preds = %3
%17 = tail call i32 (...) @print_help()
%18 = tail call i32 @exit(i32 -1)
unreachable
19: ; preds = %11, %14
%20 = phi i32 [ %15, %14 ], [ %13, %11 ]
store i32 %20, i32* %2
ret void
}