#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*/ close(int);
int initConnect(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int sendMessage(int, char *, char *, int, int /*<<< orphan*/,
                int /*<<< orphan*/ *);
int /*<<< orphan*/ strcpy(char *, char *);
int sendTimeReset(void) {
  int clientfd;
  int dwStatus = 0;
  char srcIP[16] = {0};
  char rcIP[16] = {0};
  int serverport = 3333;
  char *back_srcIP = "127.0.0.1";
  char *back_rcIP = "127.0.0.1";
  strcpy(srcIP, back_srcIP);
  strcpy(rcIP, back_rcIP);
  printf("\n===== Start to Communicate with HEAD UNIT =====\n");
  if (0 > (clientfd = initConnect(srcIP, rcIP, serverport))) {
    printf("===== Connect to HEAD UNIT Failed =====\n");
  } else {
    printf("===== Connect to HEAD UNIT Success =====\n");
    if (0 !=
        (dwStatus = sendMessage(clientfd, srcIP, rcIP, 0x00000011, 0, NULL))) {
      printf("===== Send message to HEAD UNIT Failed! =====\n");
    }
  }
  close(clientfd);
  return 0;
}


x86 assembly (clang, -O0):
<sendTimeReset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
movl   $0xd05,-0x34(%rbp)
lea    0xe63(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe58(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1030 <strcpy@plt>
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1070 <initConnect@plt>
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jle    1202 <sendTimeReset+0xa2>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
jmp    124b <sendTimeReset+0xeb>
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x11,%ecx
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%r9d
call   1080 <sendMessage@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
je     1246 <sendTimeReset+0xe6>
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
jmp    124b <sendTimeReset+0xeb>
mov    -0x4(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendTimeReset>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe94(%rip),%rbx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0xd05,%edx
call   1060 <initConnect@plt>
mov    %eax,%ebx
test   %eax,%eax
js     11df <sendTimeReset+0x8f>
lea    0xe88(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
mov    %ebx,%edi
mov    $0x11,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1070 <sendMessage@plt>
test   %eax,%eax
je     11eb <sendTimeReset+0x9b>
lea    0xe87(%rip),%rdi
jmp    11e6 <sendTimeReset+0x96>
lea    0xeac(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [50 x i8] c"\0A===== Start to Communicate with HEAD UNIT =====\0A\00"
@.str.2 = [41 x i8] c"===== Connect to HEAD UNIT Failed =====\0A\00"
@.str.3 = [42 x i8] c"===== Connect to HEAD UNIT Success =====\0A\00"
@.str.4 = [47 x i8] c"===== Send message to HEAD UNIT Failed! =====\0A\00"
define i32 @sendTimeReset() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [16 x i8]
%4 = alloca [16 x i8]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %2
%8 = bitcast [16 x i8]* %3 to i8*
%9 = bitcast [16 x i8]* %4 to i8*
store i32 3333, i32* %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %7
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%11 = load i8*, i8** %6
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%14 = load i8*, i8** %7
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%19 = load i32, i32* %5
%20 = call i32 @initConnect(i8* %17, i8* %18, i32 %19)
store i32 %20, i32* %1
%21 = icmp sgt i32 0, %20
br i1 %21, label %22, label %24
22: ; preds = %0
%23 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
br label %34
24: ; preds = %0
%25 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* %1
%27 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%29 = call i32 @sendMessage(i32 %26, i8* %27, i8* %28, i32 17, i32 0, i32* null)
store i32 %29, i32* %2
%30 = icmp ne i32 0, %29
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %24
br label %34
34: ; preds = %33, %22
%35 = load i32, i32* %1
%36 = call i32 @close(i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"127.0.0.1\00"
@str = [49 x i8] c"\0A===== Start to Communicate with HEAD UNIT =====\00"
@str.5 = [41 x i8] c"===== Connect to HEAD UNIT Success =====\00"
@str.6 = [46 x i8] c"===== Send message to HEAD UNIT Failed! =====\00"
@str.7 = [40 x i8] c"===== Connect to HEAD UNIT Failed =====\00"
define i32 @sendTimeReset() {
%1 = alloca [16 x i8]
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%5 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
%8 = call i32 @initConnect(i8* %3, i8* %4, i32 3333)
%9 = icmp slt i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.5, i64 0, i64 0))
%12 = call i32 @sendMessage(i32 %8, i8* %3, i8* %4, i32 17, i32 0, i32* null)
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10, %0
%15 = phi i8* [ getelementptr inbounds ([40 x i8], [40 x i8]* @str.7, i64 0, i64 0), %0 ], [ getelementptr inbounds ([46 x i8], [46 x i8]* @str.6, i64 0, i64 0), %10 ]
%16 = call i32 @puts(i8* dereferenceable(1) %15)
br label %17
17: ; preds = %14, %10
%18 = call i32 @close(i32 %8)
ret i32 0
}