#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 SendMsgByUdp(char *, int, char *, int);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
int main() {
  int ret, i = 0;
  char szBuf[100];
  while (1) {
    sprintf(szBuf, "第%d次发送", i);
    ret = SendMsgByUdp(szBuf, strlen(szBuf), "127.0.0.1", 9999);
    if (ret == 0)
      printf("Send UDP Success:%s %d\n", szBuf, strlen(szBuf));
    else
      printf("Send UDP Failed:%s\n", szBuf);
    sleep(1);
    i++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe89(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    %eax,%esi
lea    0xe75(%rip),%rdx
mov    $0x270f,%ecx
call   1030 <SendMsgByUdp@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11db <main+0x8b>
lea    -0x70(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11ed <main+0x9d>
lea    -0x70(%rbp),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1169 <main+0x19>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe9b(%rip),%r14
mov    %rsp,%rbx
lea    0xea0(%rip),%r15
lea    0xea3(%rip),%r12
lea    0xeb4(%rip),%r13
xor    %ebp,%ebp
jmp    11aa <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%rdx
mov    $0x270f,%ecx
call   1030 <SendMsgByUdp@plt>
test   %eax,%eax
jne    1190 <main+0x40>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    119d <main+0x4d>

LLVM IR (-O0):
@.str = [15 x i8] c"\E7\AC\AC%d\E6\AC\A1\E5\8F\91\E9\80\81\00"
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [24 x i8] c"Send UDP Success:%s %d\0A\00"
@.str.3 = [20 x i8] c"Send UDP Failed:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %0, %23
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* %3
%8 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = call i32 @SendMsgByUdp(i8* %9, i32 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 9999)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %5
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32 %18)
br label %23
20: ; preds = %5
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %15
%24 = call i32 @sleep(i32 1)
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %5
}

LLVM IR (-O2):
@.str = [15 x i8] c"\E7\AC\AC%d\E6\AC\A1\E5\8F\91\E9\80\81\00"
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [24 x i8] c"Send UDP Success:%s %d\0A\00"
@.str.3 = [20 x i8] c"Send UDP Failed:%s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %14, %0
%4 = phi i32 [ 0, %0 ], [ %16, %14 ]
%5 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @strlen(i8* %2)
%7 = call i32 @SendMsgByUdp(i8* %2, i32 %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 9999)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = call i32 @strlen(i8* %2)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32 %10)
br label %14
12: ; preds = %3
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %2)
br label %14
14: ; preds = %12, %9
%15 = call i32 @sleep(i32 1)
%16 = add nuw nsw i32 %4, 1
br label %3
}