#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 getopt(int, char **, char *);
int /*<<< orphan*/ helpMessage();
int /*<<< orphan*/ isprint(char);
int /*<<< orphan*/ optarg;
int optind;
char optopt;
int send_msgq(int, int, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strtol(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int system(char *);
int main(int argc, char **argv) {
  int cmd_opt = 0;
  int msgq_key = 0x0ADA5000;
  int msgq_type = 9;
  int tmp_key = 0;
  int tmp_type = 0;
  int res = 0;
  int r;
  while (1) {
    cmd_opt = getopt(argc, argv, "hk:t:q");
    if (cmd_opt == -1) {
      break;
    }
    if (cmd_opt != '?') {
    }
    switch (cmd_opt) {
    case 'h':
      helpMessage();
      exit(2);
      break;
    case 'k':
      tmp_key = strtol(optarg, NULL, 16);
      fprintf(stderr, "assign key = 0x%08X\n", tmp_key);
      if (tmp_key > 0) {
        msgq_key = tmp_key;
      }
      break;
    case 't':
      tmp_type = strtol(optarg, NULL, 10);
      fprintf(stderr, "assign type = %d\n", tmp_type);
      msgq_type = tmp_type;
    case 'q':
      r = system("ipcs -q");
      (void)r;
      exit(1);
    case '?':
      fprintf(stderr, "Illegal option:-%c\n", isprint(optopt) ? optopt : '#');
      exit(3);
      break;
    default:
      fprintf(stderr, "Not supported option\n");
      exit(4);
      break;
    }
  }
  char msg_str[256];
  if (argc > optind) {
    int i = 0;
    for (i = optind; i < argc; i++) {
      strcpy(msg_str, argv[i]);
      break;
    }
  }
  res = send_msgq(msgq_key, msgq_type, msg_str);
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xada5000,-0x18(%rbp)
movl   $0x9,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe1f(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11f8 <main+0x68>
jmp    13b1 <main+0x221>
cmpl   $0x3f,-0x14(%rbp)
je     1207 <main+0x77>
jmp    1207 <main+0x77>
mov    -0x14(%rbp),%eax
mov    %eax,-0x138(%rbp)
sub    $0x3f,%eax
je     131b <main+0x18b>
jmp    121e <main+0x8e>
mov    -0x138(%rbp),%eax
sub    $0x68,%eax
je     126e <main+0xde>
jmp    1232 <main+0xa2>
mov    -0x138(%rbp),%eax
sub    $0x6b,%eax
je     127f <main+0xef>
jmp    1246 <main+0xb6>
mov    -0x138(%rbp),%eax
sub    $0x71,%eax
je     1302 <main+0x172>
jmp    125a <main+0xca>
mov    -0x138(%rbp),%eax
sub    $0x74,%eax
je     12c8 <main+0x138>
jmp    138b <main+0x1fb>
mov    $0x0,%al
call   1050 <helpMessage@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1080 <strtol@plt>
mov    %eax,-0x20(%rbp)
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xd5b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x0,-0x20(%rbp)
jle    12c3 <main+0x133>
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    13ac <main+0x21c>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,-0x24(%rbp)
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
lea    0xd27(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    0xd25(%rip),%rdi
call   1060 <system@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2ca6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x13c(%rbp)
mov    0x2caf(%rip),%rax
movsbl (%rax),%edi
call   1090 <isprint@plt>
cmp    $0x0,%eax
je     1357 <main+0x1c7>
mov    0x2c97(%rip),%rax
movsbl (%rax),%eax
mov    %eax,-0x140(%rbp)
jmp    1367 <main+0x1d7>
mov    $0x23,%eax
mov    %eax,-0x140(%rbp)
jmp    1367 <main+0x1d7>
mov    -0x13c(%rbp),%edi
mov    -0x140(%rbp),%edx
lea    0xcbc(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x3,%edi
call   10b0 <exit@plt>
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
lea    0xcaf(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x4,%edi
call   10b0 <exit@plt>
jmp    11d3 <main+0x43>
mov    -0x8(%rbp),%eax
mov    0x2c1d(%rip),%rcx
cmp    (%rcx),%eax
jle    140b <main+0x27b>
movl   $0x0,-0x134(%rbp)
mov    0x2c04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
mov    -0x134(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1406 <main+0x276>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
jmp    140b <main+0x27b>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
lea    -0x130(%rbp),%rdx
call   1040 <send_msgq@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r14
mov    %edi,%r13d
mov    $0xada5000,%ebx
lea    0xe4d(%rip),%r15
lea    0xe4d(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10a0 <getopt@plt>
cmp    $0x6b,%eax
jne    1206 <main+0x76>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <strtol@plt>
mov    %eax,%ebp
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %ebp,%ebp
cmovg  %ebp,%ebx
jmp    11c0 <main+0x30>
cmp    $0x3e,%eax
jg     1250 <main+0xc0>
cmp    $0xffffffff,%eax
jne    1307 <main+0x177>
mov    0x2dbd(%rip),%rax
movslq (%rax),%rax
cmp    %r13d,%eax
jge    122f <main+0x9f>
mov    (%r14,%rax,8),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    %rsp,%rdx
mov    %ebx,%edi
mov    $0x9,%esi
call   1040 <send_msgq@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x70,%eax
jg     1274 <main+0xe4>
cmp    $0x3f,%eax
je     12c6 <main+0x136>
cmp    $0x68,%eax
jne    1307 <main+0x177>
xor    %eax,%eax
call   1050 <helpMessage@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
cmp    $0x71,%eax
je     12b0 <main+0x120>
cmp    $0x74,%eax
jne    1307 <main+0x177>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    0x2d2a(%rip),%rcx
mov    (%rcx),%edi
lea    0xd75(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xd77(%rip),%rdi
call   1060 <system@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%ebx
mov    0x2d0a(%rip),%rbp
movsbl 0x0(%rbp),%edi
call   1090 <isprint@plt>
test   %eax,%eax
movsbl 0x0(%rbp),%eax
mov    $0x23,%edx
cmovne %eax,%edx
lea    0xd42(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x3,%edi
call   10b0 <exit@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
lea    0xd33(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x4,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"hk:t:q\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"assign key = 0x%08X\0A\00"
@.str.2 = [18 x i8] c"assign type = %d\0A\00"
@.str.3 = [8 x i8] c"ipcs -q\00"
@.str.4 = [20 x i8] c"Illegal option:-%c\0A\00"
@optopt = global i8 0
@.str.5 = [22 x i8] c"Not supported option\0A\00"
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [256 x i8]
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 182079488, i32* %7
store i32 9, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %15
15: ; preds = %2, %70
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %22
21: ; preds = %15
br label %71
22: ; preds = %15
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 63
br i1 %24, label %25, label %26
25: ; preds = %22
br label %26
26: ; preds = %25, %22
%27 = load i32, i32* %6
switch i32 %27, label %66 [
i32 104, label %28
i32 107, label %31
i32 116, label %42
i32 113, label %49
i32 63, label %53
]
28: ; preds = %26
%29 = call i32 (...) @helpMessage()
%30 = call i32 @exit(i32 2)
unreachable
31: ; preds = %26
%32 = load i32, i32* @optarg
%33 = call i32 @strtol(i32 %32, i32* null, i32 16)
store i32 %33, i32* %9
%34 = load i32, i32* @stderr
%35 = load i32, i32* %9
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %9
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %31
%40 = load i32, i32* %9
store i32 %40, i32* %7
br label %41
41: ; preds = %39, %31
br label %70
42: ; preds = %26
%43 = load i32, i32* @optarg
%44 = call i32 @strtol(i32 %43, i32* null, i32 10)
store i32 %44, i32* %10
%45 = load i32, i32* @stderr
%46 = load i32, i32* %10
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %10
store i32 %48, i32* %8
br label %49
49: ; preds = %26, %42
%50 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i32 %50, i32* %12
%51 = load i32, i32* %12
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %26
%54 = load i32, i32* @stderr
%55 = load i8, i8* @optopt
%56 = call i32 @isprint(i8 signext %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %53
%59 = load i8, i8* @optopt
%60 = sext i8 %59 to i32
br label %62
61: ; preds = %53
br label %62
62: ; preds = %61, %58
%63 = phi i32 [ %60, %58 ], [ 35, %61 ]
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %63)
%65 = call i32 @exit(i32 3)
unreachable
66: ; preds = %26
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%69 = call i32 @exit(i32 4)
unreachable
70: ; preds = %41
br label %15
71: ; preds = %21
%72 = load i32, i32* %4
%73 = load i32, i32* @optind
%74 = icmp sgt i32 %72, %73
br i1 %74, label %75, label %93
75: ; preds = %71
store i32 0, i32* %14
%76 = load i32, i32* @optind
store i32 %76, i32* %14
br label %77
77: ; preds = %89, %75
%78 = load i32, i32* %14
%79 = load i32, i32* %4
%80 = icmp slt i32 %78, %79
br i1 %80, label %81, label %92
81: ; preds = %77
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%83 = load i8**, i8*** %5
%84 = load i32, i32* %14
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8*, i8** %83, i64 %85
%87 = load i8*, i8** %86
%88 = call i32 @strcpy(i8* %82, i8* %87)
br label %92
89: ; No predecessors!
%90 = load i32, i32* %14
%91 = add nsw i32 %90, 1
store i32 %91, i32* %14
br label %77
92: ; preds = %81, %77
br label %93
93: ; preds = %92, %71
%94 = load i32, i32* %7
%95 = load i32, i32* %8
%96 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%97 = call i32 @send_msgq(i32 %94, i32 %95, i8* %96)
store i32 %97, i32* %11
%98 = load i32, i32* %11
ret i32 %98
}

LLVM IR (-O2):
@.str = [7 x i8] c"hk:t:q\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"assign key = 0x%08X\0A\00"
@.str.2 = [18 x i8] c"assign type = %d\0A\00"
@.str.3 = [8 x i8] c"ipcs -q\00"
@.str.4 = [20 x i8] c"Illegal option:-%c\0A\00"
@optopt = global i8 0
@.str.5 = [22 x i8] c"Not supported option\0A\00"
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [256 x i8]
br label %4
4: ; preds = %10, %2
%5 = phi i32 [ 182079488, %2 ], [ %16, %10 ]
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %35 [
i32 -1, label %39
i32 104, label %7
i32 107, label %10
i32 116, label %17
i32 113, label %22
i32 63, label %25
]
7: ; preds = %4
%8 = tail call i32 (...) @helpMessage()
%9 = tail call i32 @exit(i32 2)
unreachable
10: ; preds = %4
%11 = load i32, i32* @optarg
%12 = tail call i32 @strtol(i32 %11, i32* null, i32 16)
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%15 = icmp sgt i32 %12, 0
%16 = select i1 %15, i32 %12, i32 %5
br label %4
17: ; preds = %4
%18 = load i32, i32* @optarg
%19 = tail call i32 @strtol(i32 %18, i32* null, i32 10)
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %22
22: ; preds = %4, %17
%23 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %4
%26 = load i32, i32* @stderr
%27 = load i8, i8* @optopt
%28 = tail call i32 @isprint(i8 signext %27)
%29 = icmp eq i32 %28, 0
%30 = load i8, i8* @optopt
%31 = sext i8 %30 to i32
%32 = select i1 %29, i32 35, i32 %31
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = tail call i32 @exit(i32 3)
unreachable
35: ; preds = %4
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%38 = tail call i32 @exit(i32 4)
unreachable
39: ; preds = %4
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%41 = load i32, i32* @optind
%42 = icmp slt i32 %41, %0
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = sext i32 %41 to i64
%45 = getelementptr inbounds i8*, i8** %1, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 @strcpy(i8* %40, i8* %46)
br label %48
48: ; preds = %43, %39
%49 = call i32 @send_msgq(i32 %5, i32 9, i8* %40)
ret i32 %49
}