#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) {
  char *st, *P, buf[256];
  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)
lea    -0x140(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x140(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1210 <GetStrParam+0xd0>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    11d1 <GetStrParam+0x91>
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    11dd <GetStrParam+0x9d>
movl   $0xffffffff,-0x4(%rbp)
jmp    126d <GetStrParam+0x12d>
lea    -0x140(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    120b <GetStrParam+0xcb>
movl   $0xffffffff,-0x4(%rbp)
jmp    126d <GetStrParam+0x12d>
jmp    1210 <GetStrParam+0xd0>
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     1266 <GetStrParam+0x126>
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    1234 <GetStrParam+0xf4>
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 i8*
%15 = alloca i8*
%16 = 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
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%18 = load i8*, i8** %11
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%21 = call i8* @strtok(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %14
%22 = load i8*, i8** %14
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %50
24: ; preds = %6
%25 = load i32*, i32** %10
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %8
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %42
30: ; preds = %24
%31 = load i32*, i32** %10
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %31
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%35 = load i8**, i8*** %9
%36 = load i32*, i32** %10
%37 = load i32, i32* %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %35, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @strcpy(i8* %34, i8* %40)
br label %43
42: ; preds = %24
store i32 -1, i32* %7
br label %72
43: ; preds = %30
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%45 = call i8* @strtok(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %45, i8** %14
%46 = load i8*, i8** %14
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %49
48: ; preds = %43
store i32 -1, i32* %7
br label %72
49: ; preds = %43
br label %50
50: ; preds = %49, %6
%51 = load i8*, i8** %12
%52 = load i8*, i8** %14
%53 = load i32, i32* %13
%54 = call i32 @strncpy(i8* %51, i8* %52, i32 %53)
%55 = load i8*, i8** %12
%56 = load i32, i32* %13
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8 0, i8* %58
%59 = load i8*, i8** %12
store i8* %59, i8** %15
br label %60
60: ; preds = %64, %50
%61 = load i8*, i8** %15
%62 = load i8, i8* %61
%63 = icmp ne i8 %62, 0
br i1 %63, label %64, label %71
64: ; preds = %60
%65 = load i8*, i8** %15
%66 = load i8, i8* %65
%67 = call signext i8 @toupper(i8 signext %66)
%68 = load i8*, i8** %15
store i8 %67, i8* %68
%69 = load i8*, i8** %15
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %15
br label %60
71: ; preds = %60
store i32 0, i32* %7
br label %72
72: ; preds = %71, %48, %42
%73 = load i32, i32* %7
ret i32 %73
}

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
}