#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*/ uString;

/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ logIT(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ my_send(int, char *, int);
int parseLine(char *, char *, int *, char *, int);
int /*<<< orphan*/ receive(int, char *, int, unsigned long *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ waitfor(int, char *, int);
int execCmd(char *cmd, int fd, char *recvBuf, int recvLen) {
  char uString[100];
  logIT(LOG_INFO, "Execute %s", cmd);
  char hex[4096];
  int token;
  int hexlen = 0;
  int t;
  unsigned long etime;
  token = parseLine(cmd, hex, &hexlen, uString, sizeof(uString));
  switch (token) {
  case 1:
    if (!waitfor(fd, hex, hexlen)) {
      logIT(LOG_ERR, "%s", "parser - execCmd - WAIT : Wait error , abort");
      return (-1);
    }
    break;
  case 3:
    if (!my_send(fd, hex, hexlen)) {
      logIT(LOG_ERR, "%s", "parser - execCmd - SEND : Wait error , abort");
      exit(1);
    }
    break;
  case 2:
    if (hexlen > recvLen) {
      logIT(LOG_ERR,
            "parser - execCmd - Recv Buffer zu klein. Ist: %d Soll %dRecv "
            "Buffer too small . Is : %d ; target : %d",
            recvLen, hexlen);
      hexlen = recvLen;
    }
    etime = 0;
    if (receive(fd, recvBuf, hexlen, &etime) <= 0) {
      logIT(LOG_ERR, "%s", "Fehler recv, Abbruch");
      exit(1);
    }
    logIT(LOG_INFO, "Recv: %ld ms", etime);
    return (hexlen);
    break;
  case 4:
    t = (int)hexlen / 1000;
    logIT(LOG_INFO, "Warte %i s", t);
    sleep(t);
    break;
  default:
    logIT(LOG_INFO, "unbekannter Befehl: %s", cmd);
  }
  return (0);
}


x86 assembly (clang, -O0):
<execCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10b0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe73(%rip),%rsi
xor    %eax,%eax
call   1080 <logIT@plt>
movl   $0x0,-0x1098(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1090(%rbp),%rsi
lea    -0x1098(%rbp),%rdx
lea    -0x90(%rbp),%rcx
mov    $0x64,%r8d
call   1050 <parseLine@plt>
mov    %eax,-0x1094(%rbp)
mov    -0x1094(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10b0(%rbp)
sub    $0x3,%eax
ja     139c <execCmd+0x22c>
mov    -0x10b0(%rbp),%rax
lea    0xdff(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x14(%rbp),%edi
lea    -0x1090(%rbp),%rsi
mov    -0x1098(%rbp),%edx
call   1060 <waitfor@plt>
cmp    $0x0,%eax
jne    1252 <execCmd+0xe2>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xee4(%rip),%rsi
lea    0xddc(%rip),%rdx
mov    $0x0,%al
call   1080 <logIT@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13be <execCmd+0x24e>
jmp    13b7 <execCmd+0x247>
mov    -0x14(%rbp),%edi
lea    -0x1090(%rbp),%rsi
mov    -0x1098(%rbp),%edx
call   1030 <my_send@plt>
cmp    $0x0,%eax
jne    129d <execCmd+0x12d>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
lea    0xdbc(%rip),%rdx
mov    $0x0,%al
call   1080 <logIT@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    13b7 <execCmd+0x247>
mov    -0x1098(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    12da <execCmd+0x16a>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
mov    -0x1098(%rbp),%ecx
lea    0xdab(%rip),%rsi
mov    $0x0,%al
call   1080 <logIT@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1098(%rbp)
movq   $0x0,-0x10a8(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x1098(%rbp),%edx
lea    -0x10a8(%rbp),%rcx
call   1040 <receive@plt>
cmp    $0x0,%eax
jg     132f <execCmd+0x1bf>
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
lea    0xdbd(%rip),%rdx
mov    $0x0,%al
call   1080 <logIT@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
mov    -0x10a8(%rbp),%rdx
lea    0xdaa(%rip),%rsi
mov    $0x0,%al
call   1080 <logIT@plt>
mov    -0x1098(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13be <execCmd+0x24e>
mov    -0x1098(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x109c(%rbp)
mov    0x2c6a(%rip),%rax
mov    (%rax),%edi
mov    -0x109c(%rbp),%edx
lea    0xd78(%rip),%rsi
mov    $0x0,%al
call   1080 <logIT@plt>
mov    -0x109c(%rbp),%edi
call   1090 <sleep@plt>
jmp    13b7 <execCmd+0x247>
mov    0x2c3d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd58(%rip),%rsi
mov    $0x0,%al
call   1080 <logIT@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execCmd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1088,%rsp
mov    %ecx,%r12d
mov    %rdx,%r15
mov    %esi,%r14d
mov    %rdi,%rbp
mov    0x2e4c(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe71(%rip),%rsi
xor    %ebx,%ebx
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <logIT@plt>
movl   $0x0,0x4(%rsp)
lea    0x80(%rsp),%rsi
lea    0x4(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %rbp,%rdi
mov    $0x64,%r8d
call   1050 <parseLine@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     12a7 <execCmd+0x137>
lea    0xe1a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x4(%rsp),%edx
lea    0x80(%rsp),%rsi
mov    %r14d,%edi
call   1060 <waitfor@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    1326 <execCmd+0x1b6>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
lea    0xeff(%rip),%rsi
lea    0xdf7(%rip),%rdx
xor    %eax,%eax
call   1080 <logIT@plt>
mov    $0xffffffff,%ebx
jmp    1326 <execCmd+0x1b6>
mov    0x4(%rsp),%edx
lea    0x80(%rsp),%rsi
mov    %r14d,%edi
call   1030 <my_send@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    1326 <execCmd+0x1b6>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
lea    0xeb9(%rip),%rsi
lea    0xdde(%rip),%rdx
jmp    1351 <execCmd+0x1e1>
movslq 0x4(%rsp),%rax
imul   $0x10624dd3,%rax,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
sar    $0x26,%rbp
add    %eax,%ebp
mov    0x0(%r13),%edi
lea    0xe6a(%rip),%rsi
xor    %ebx,%ebx
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <logIT@plt>
mov    %ebp,%edi
call   1090 <sleep@plt>
jmp    1326 <execCmd+0x1b6>
mov    0x0(%r13),%edi
lea    0xe56(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <logIT@plt>
jmp    1326 <execCmd+0x1b6>
mov    0x4(%rsp),%ecx
cmp    %r12d,%ecx
jle    12e8 <execCmd+0x178>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
lea    0xd9e(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <logIT@plt>
mov    %r12d,0x4(%rsp)
jmp    12eb <execCmd+0x17b>
mov    %ecx,%r12d
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rcx
mov    %r14d,%edi
mov    %r15,%rsi
mov    %r12d,%edx
call   1040 <receive@plt>
test   %eax,%eax
jle    133a <execCmd+0x1ca>
mov    0x0(%r13),%edi
mov    0x8(%rsp),%rdx
lea    0xdd5(%rip),%rsi
xor    %eax,%eax
call   1080 <logIT@plt>
mov    0x4(%rsp),%ebx
mov    %ebx,%eax
add    $0x1088,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
lea    0xd8a(%rip),%rdx
xor    %eax,%eax
call   1080 <logIT@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@LOG_INFO = global i32 0
@.str = [11 x i8] c"Execute %s\00"
@LOG_ERR = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [45 x i8] c"parser - execCmd - WAIT : Wait error , abort\00"
@.str.3 = [45 x i8] c"parser - execCmd - SEND : Wait error , abort\00"
@.str.4 = [102 x i8] c"parser - execCmd - Recv Buffer zu klein. Ist: %d Soll %dRecv Buffer too small . Is : %d ; target : %d\00"
@.str.5 = [21 x i8] c"Fehler recv, Abbruch\00"
@.str.6 = [13 x i8] c"Recv: %ld ms\00"
@.str.7 = [11 x i8] c"Warte %i s\00"
@.str.8 = [23 x i8] c"unbekannter Befehl: %s\00"
define i32 @execCmd(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [100 x i8]
%11 = alloca [4096 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i64
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%16 = load i32, i32* @LOG_INFO
%17 = load i8*, i8** %6
%18 = call i32 (i32, i8*, ...) @logIT(i32 %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 0, i32* %13
%19 = load i8*, i8** %6
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%22 = call i32 @parseLine(i8* %19, i8* %20, i32* %13, i8* %21, i32 100)
store i32 %22, i32* %12
%23 = load i32, i32* %12
switch i32 %23, label %78 [
i32 1, label %24
i32 3, label %34
i32 2, label %45
i32 4, label %70
]
24: ; preds = %4
%25 = load i32, i32* %7
%26 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%27 = load i32, i32* %13
%28 = call i32 @waitfor(i32 %25, i8* %26, i32 %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %24
%31 = load i32, i32* @LOG_ERR
%32 = call i32 (i32, i8*, ...) @logIT(i32 %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %83
33: ; preds = %24
br label %82
34: ; preds = %4
%35 = load i32, i32* %7
%36 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%37 = load i32, i32* %13
%38 = call i32 @my_send(i32 %35, i8* %36, i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %34
%41 = load i32, i32* @LOG_ERR
%42 = call i32 (i32, i8*, ...) @logIT(i32 %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %34
br label %82
45: ; preds = %4
%46 = load i32, i32* %13
%47 = load i32, i32* %9
%48 = icmp sgt i32 %46, %47
br i1 %48, label %49, label %55
49: ; preds = %45
%50 = load i32, i32* @LOG_ERR
%51 = load i32, i32* %9
%52 = load i32, i32* %13
%53 = call i32 (i32, i8*, ...) @logIT(i32 %50, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.4, i64 0, i64 0), i32 %51, i32 %52)
%54 = load i32, i32* %9
store i32 %54, i32* %13
br label %55
55: ; preds = %49, %45
store i64 0, i64* %15
%56 = load i32, i32* %7
%57 = load i8*, i8** %8
%58 = load i32, i32* %13
%59 = call i32 @receive(i32 %56, i8* %57, i32 %58, i64* %15)
%60 = icmp sle i32 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %55
%62 = load i32, i32* @LOG_ERR
%63 = call i32 (i32, i8*, ...) @logIT(i32 %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %55
%66 = load i32, i32* @LOG_INFO
%67 = load i64, i64* %15
%68 = call i32 (i32, i8*, ...) @logIT(i32 %66, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i64 %67)
%69 = load i32, i32* %13
store i32 %69, i32* %5
br label %83
70: ; preds = %4
%71 = load i32, i32* %13
%72 = sdiv i32 %71, 1000
store i32 %72, i32* %14
%73 = load i32, i32* @LOG_INFO
%74 = load i32, i32* %14
%75 = call i32 (i32, i8*, ...) @logIT(i32 %73, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %74)
%76 = load i32, i32* %14
%77 = call i32 @sleep(i32 %76)
br label %82
78: ; preds = %4
%79 = load i32, i32* @LOG_INFO
%80 = load i8*, i8** %6
%81 = call i32 (i32, i8*, ...) @logIT(i32 %79, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %80)
br label %82
82: ; preds = %78, %70, %44, %33
store i32 0, i32* %5
br label %83
83: ; preds = %82, %65, %30
%84 = load i32, i32* %5
ret i32 %84
}

LLVM IR (-O2):
@LOG_INFO = global i32 0
@.str = [11 x i8] c"Execute %s\00"
@LOG_ERR = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [45 x i8] c"parser - execCmd - WAIT : Wait error , abort\00"
@.str.3 = [45 x i8] c"parser - execCmd - SEND : Wait error , abort\00"
@.str.4 = [102 x i8] c"parser - execCmd - Recv Buffer zu klein. Ist: %d Soll %dRecv Buffer too small . Is : %d ; target : %d\00"
@.str.5 = [21 x i8] c"Fehler recv, Abbruch\00"
@.str.6 = [13 x i8] c"Recv: %ld ms\00"
@.str.7 = [11 x i8] c"Warte %i s\00"
@.str.8 = [23 x i8] c"unbekannter Befehl: %s\00"
define i32 @execCmd(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca [100 x i8]
%6 = alloca [4096 x i8]
%7 = alloca i32
%8 = alloca i64
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* @LOG_INFO
%11 = tail call i32 (i32, i8*, ...) @logIT(i32 %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%13 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%14 = bitcast i64* %8 to i8*
%15 = call i32 @parseLine(i8* %0, i8* %12, i32* %7, i8* %9, i32 100)
switch i32 %15, label %56 [
i32 1, label %16
i32 3, label %23
i32 2, label %31
i32 4, label %50
]
16: ; preds = %4
%17 = load i32, i32* %7
%18 = call i32 @waitfor(i32 %1, i8* %12, i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %59
20: ; preds = %16
%21 = load i32, i32* @LOG_ERR
%22 = call i32 (i32, i8*, ...) @logIT(i32 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %59
23: ; preds = %4
%24 = load i32, i32* %7
%25 = call i32 @my_send(i32 %1, i8* %12, i32 %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %59
27: ; preds = %23
%28 = load i32, i32* @LOG_ERR
%29 = call i32 (i32, i8*, ...) @logIT(i32 %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %4
%32 = load i32, i32* %7
%33 = icmp sgt i32 %32, %3
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* @LOG_ERR
%36 = call i32 (i32, i8*, ...) @logIT(i32 %35, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.4, i64 0, i64 0), i32 %3, i32 %32)
store i32 %3, i32* %7
br label %37
37: ; preds = %34, %31
%38 = phi i32 [ %3, %34 ], [ %32, %31 ]
store i64 0, i64* %8
%39 = call i32 @receive(i32 %1, i8* %2, i32 %38, i64* %8)
%40 = icmp slt i32 %39, 1
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i32, i32* @LOG_ERR
%43 = call i32 (i32, i8*, ...) @logIT(i32 %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %37
%46 = load i32, i32* @LOG_INFO
%47 = load i64, i64* %8
%48 = call i32 (i32, i8*, ...) @logIT(i32 %46, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i64 %47)
%49 = load i32, i32* %7
br label %59
50: ; preds = %4
%51 = load i32, i32* %7
%52 = sdiv i32 %51, 1000
%53 = load i32, i32* @LOG_INFO
%54 = call i32 (i32, i8*, ...) @logIT(i32 %53, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %52)
%55 = call i32 @sleep(i32 %52)
br label %59
56: ; preds = %4
%57 = load i32, i32* @LOG_INFO
%58 = call i32 (i32, i8*, ...) @logIT(i32 %57, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %0)
br label %59
59: ; preds = %50, %56, %16, %23, %45, %20
%60 = phi i32 [ %49, %45 ], [ -1, %20 ], [ 0, %23 ], [ 0, %16 ], [ 0, %56 ], [ 0, %50 ]
ret i32 %60
}