#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*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strtok(char *, char *);
char toupper(char);
int GetStrParam(int argc, char **argv, int *argn, char *pos, char *param,
                int len) {
  int i;
  char *st, *P, buf[256];
  i = 0;
  strcpy(buf, pos);
  st = strtok(buf, "\t,/");
  if (st == NULL) {
    if ((*argn) + 1 < argc) {
      (*argn)++;
      strcpy(buf, argv[*argn]);
    } else
      return -1;
    st = strtok(buf, "\t,/");
    if (st == NULL)
      return -1;
  }
  strncpy(param, st, len);
  param[len] = '\0';
  P = param;
  while (*P) {
    *P = toupper(*P);
    P++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<GetStrParam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    -0x140(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x140(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1217 <GetStrParam+0xd7>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    11d8 <GetStrParam+0x98>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcpy@plt>
jmp    11e4 <GetStrParam+0xa4>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <GetStrParam+0x134>
lea    -0x140(%rbp),%rdi
lea    0xe0e(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1212 <GetStrParam+0xd2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <GetStrParam+0x134>
jmp    1217 <GetStrParam+0xd7>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmpb   $0x0,(%rax)
je     126d <GetStrParam+0x12d>
mov    -0x40(%rbp),%rax
movsbl (%rax),%edi
call   1050 <toupper@plt>
mov    %al,%cl
mov    -0x40(%rbp),%rax
mov    %cl,(%rax)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    123b <GetStrParam+0xfb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetStrParam>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %r9d,%r12d
mov    %r8,%rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %edi,%r13d
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rcx,%rsi
call   1040 <strcpy@plt>
lea    0xe8b(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     11c8 <GetStrParam+0x88>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
movslq %r12d,%rax
movb   $0x0,(%rbx,%rax,1)
mov    (%rbx),%al
xor    %r14d,%r14d
test   %al,%al
je     1207 <GetStrParam+0xc7>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
call   1050 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11b0 <GetStrParam+0x70>
jmp    1207 <GetStrParam+0xc7>
mov    %r14,%rdx
movslq (%r15),%rax
lea    0x1(%rax),%ecx
mov    $0xffffffff,%r14d
cmp    %r13d,%ecx
jge    1207 <GetStrParam+0xc7>
mov    %ecx,(%r15)
mov    0x8(%rdx,%rax,8),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1040 <strcpy@plt>
lea    0xe0a(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
jne    1182 <GetStrParam+0x42>
mov    %r14d,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\09,/\00"
define i32 @GetStrParam(i32 %0, i8** %1, i32* %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca [256 x i8]
store i32 %0, i32* %8
store i8** %1, i8*** %9
store i32* %2, i32** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store i32 0, i32* %14
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%19 = load i8*, i8** %11
%20 = call i32 @strcpy(i8* %18, i8* %19)
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%22 = call i8* @strtok(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %15
%23 = load i8*, i8** %15
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %51
25: ; preds = %6
%26 = load i32*, i32** %10
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1
%29 = load i32, i32* %8
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %43
31: ; preds = %25
%32 = load i32*, i32** %10
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %32
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%36 = load i8**, i8*** %9
%37 = load i32*, i32** %10
%38 = load i32, i32* %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %36, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 @strcpy(i8* %35, i8* %41)
br label %44
43: ; preds = %25
store i32 -1, i32* %7
br label %73
44: ; preds = %31
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%46 = call i8* @strtok(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %46, i8** %15
%47 = load i8*, i8** %15
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %50
49: ; preds = %44
store i32 -1, i32* %7
br label %73
50: ; preds = %44
br label %51
51: ; preds = %50, %6
%52 = load i8*, i8** %12
%53 = load i8*, i8** %15
%54 = load i32, i32* %13
%55 = call i32 @strncpy(i8* %52, i8* %53, i32 %54)
%56 = load i8*, i8** %12
%57 = load i32, i32* %13
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 0, i8* %59
%60 = load i8*, i8** %12
store i8* %60, i8** %16
br label %61
61: ; preds = %65, %51
%62 = load i8*, i8** %16
%63 = load i8, i8* %62
%64 = icmp ne i8 %63, 0
br i1 %64, label %65, label %72
65: ; preds = %61
%66 = load i8*, i8** %16
%67 = load i8, i8* %66
%68 = call signext i8 @toupper(i8 signext %67)
%69 = load i8*, i8** %16
store i8 %68, i8* %69
%70 = load i8*, i8** %16
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %16
br label %61
72: ; preds = %61
store i32 0, i32* %7
br label %73
73: ; preds = %72, %49, %43
%74 = load i32, i32* %7
ret i32 %74
}

LLVM IR (-O2):
@.str = [4 x i8] c"\09,/\00"
define i32 @GetStrParam(i32 %0, i8** nocapture %1, i32* nocapture %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca [256 x i8]
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* %3)
%10 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %23
12: ; preds = %6
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
%15 = icmp slt i32 %14, %0
br i1 %15, label %16, label %37
16: ; preds = %12
store i32 %14, i32* %2
%17 = sext i32 %14 to i64
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @strcpy(i8* %8, i8* %19)
%21 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %37, label %23
23: ; preds = %16, %6
%24 = phi i8* [ %21, %16 ], [ %10, %6 ]
%25 = call i32 @strncpy(i8* %4, i8* %24, i32 %5)
%26 = sext i32 %5 to i64
%27 = getelementptr inbounds i8, i8* %4, i64 %26
store i8 0, i8* %27
%28 = load i8, i8* %4
%29 = icmp eq i8 %28, 0
br i1 %29, label %37, label %30
30: ; preds = %23, %30
%31 = phi i8 [ %35, %30 ], [ %28, %23 ]
%32 = phi i8* [ %34, %30 ], [ %4, %23 ]
%33 = call signext i8 @toupper(i8 signext %31)
store i8 %33, i8* %32
%34 = getelementptr inbounds i8, i8* %32, i64 1
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %30
37: ; preds = %30, %23, %16, %12
%38 = phi i32 [ -1, %12 ], [ -1, %16 ], [ 0, %23 ], [ 0, %30 ]
ret i32 %38
}