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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mmsleep(int);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int add_port_vlan_h3c(char *setport, int vlanid, int rfd, int wfd) {
  char buf[2048];
  write(wfd, "system-view\r", 12);
  mmsleep(70);
  read(rfd, buf, sizeof(buf));
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "interface %s\r", setport);
  write(wfd, buf, strlen(buf));
  mmsleep(70);
  read(rfd, buf, sizeof(buf));
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "port link-type trunk\r");
  write(wfd, buf, strlen(buf));
  mmsleep(70);
  read(rfd, buf, sizeof(buf));
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "port trunk permit vlan %d\r", vlanid);
  write(wfd, buf, strlen(buf));
  mmsleep(70);
  read(rfd, buf, sizeof(buf));
  write(wfd, "quit\r", 5);
  mmsleep(70);
  read(rfd, buf, sizeof(buf));
  write(wfd, "quit\r", 5);
  mmsleep(70);
  read(rfd, buf, sizeof(buf));
}


x86 assembly (clang, -O0):
<add_port_vlan_h3c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
lea    0xe7e(%rip),%rsi
mov    $0xc,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    -0x18(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1060 <read@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x84c(%rbp)
lea    -0x820(%rbp),%rax
mov    %rax,-0x848(%rbp)
lea    -0x820(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x84c(%rbp),%edi
mov    -0x848(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    -0x18(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1060 <read@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
lea    -0x820(%rbp),%rdi
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x83c(%rbp)
lea    -0x820(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    -0x820(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x83c(%rbp),%edi
mov    -0x838(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    -0x18(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1060 <read@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
lea    -0x820(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xd65(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x82c(%rbp)
lea    -0x820(%rbp),%rax
mov    %rax,-0x828(%rbp)
lea    -0x820(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x82c(%rbp),%edi
mov    -0x828(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    -0x18(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1060 <read@plt>
mov    -0x1c(%rbp),%edi
lea    0xd1a(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    -0x18(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1060 <read@plt>
mov    -0x1c(%rbp),%edi
lea    0xce8(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    -0x18(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1060 <read@plt>
mov    -0x4(%rbp),%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_port_vlan_h3c>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r12
lea    0xe7f(%rip),%rsi
mov    %ecx,%edi
mov    $0xc,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    %rsp,%rbx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x800,%edx
call   1060 <read@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
lea    0xe4d(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x800,%edx
call   1060 <read@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
movabs $0xd6b6e75727420,%rax
mov    %rax,0xe(%rsp)
movups 0xdfb(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x800,%edx
call   1060 <read@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
lea    0xdc9(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x800,%edx
call   1060 <read@plt>
lea    0xda2(%rip),%r15
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x800,%edx
call   1060 <read@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    $0x46,%edi
call   1080 <mmsleep@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x800,%edx
call   1060 <read@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"system-view\0D\00"
@.str.1 = [14 x i8] c"interface %s\0D\00"
@.str.2 = [22 x i8] c"port link-type trunk\0D\00"
@.str.3 = [27 x i8] c"port trunk permit vlan %d\0D\00"
@.str.4 = [6 x i8] c"quit\0D\00"
define i32 @add_port_vlan_h3c(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [2048 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load i32, i32* %9
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 12)
%13 = call i32 @mmsleep(i32 70)
%14 = load i32, i32* %8
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%16 = call i32 @read(i32 %14, i8* %15, i32 2048)
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%18 = call i32 @memset(i8* %17, i32 0, i32 2048)
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%20 = load i8*, i8** %6
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* %9
%23 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%24 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @write(i32 %22, i8* %23, i32 %25)
%27 = call i32 @mmsleep(i32 70)
%28 = load i32, i32* %8
%29 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%30 = call i32 @read(i32 %28, i8* %29, i32 2048)
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%32 = call i32 @memset(i8* %31, i32 0, i32 2048)
%33 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %33, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* %9
%36 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%37 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%38 = call i32 @strlen(i8* %37)
%39 = call i32 @write(i32 %35, i8* %36, i32 %38)
%40 = call i32 @mmsleep(i32 70)
%41 = load i32, i32* %8
%42 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%43 = call i32 @read(i32 %41, i8* %42, i32 2048)
%44 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%45 = call i32 @memset(i8* %44, i32 0, i32 2048)
%46 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%47 = load i32, i32* %7
%48 = call i32 (i8*, i8*, ...) @sprintf(i8* %46, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %9
%50 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%51 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%52 = call i32 @strlen(i8* %51)
%53 = call i32 @write(i32 %49, i8* %50, i32 %52)
%54 = call i32 @mmsleep(i32 70)
%55 = load i32, i32* %8
%56 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%57 = call i32 @read(i32 %55, i8* %56, i32 2048)
%58 = load i32, i32* %9
%59 = call i32 @write(i32 %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%60 = call i32 @mmsleep(i32 70)
%61 = load i32, i32* %8
%62 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%63 = call i32 @read(i32 %61, i8* %62, i32 2048)
%64 = load i32, i32* %9
%65 = call i32 @write(i32 %64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%66 = call i32 @mmsleep(i32 70)
%67 = load i32, i32* %8
%68 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%69 = call i32 @read(i32 %67, i8* %68, i32 2048)
%70 = load i32, i32* %5
ret i32 %70
}

LLVM IR (-O2):
@.str = [13 x i8] c"system-view\0D\00"
@.str.1 = [14 x i8] c"interface %s\0D\00"
@.str.2 = [22 x i8] c"port link-type trunk\0D\00"
@.str.3 = [27 x i8] c"port trunk permit vlan %d\0D\00"
@.str.4 = [6 x i8] c"quit\0D\00"
define i32 @add_port_vlan_h3c(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [2048 x i8]
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%7 = tail call i32 @write(i32 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 12)
%8 = tail call i32 @mmsleep(i32 70)
%9 = call i32 @read(i32 %2, i8* %6, i32 2048)
%10 = call i32 @memset(i8* %6, i32 0, i32 2048)
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = call i32 @strlen(i8* %6)
%13 = call i32 @write(i32 %3, i8* %6, i32 %12)
%14 = call i32 @mmsleep(i32 70)
%15 = call i32 @read(i32 %2, i8* %6, i32 2048)
%16 = call i32 @memset(i8* %6, i32 0, i32 2048)
%17 = call i32 @strlen(i8* %6)
%18 = call i32 @write(i32 %3, i8* %6, i32 %17)
%19 = call i32 @mmsleep(i32 70)
%20 = call i32 @read(i32 %2, i8* %6, i32 2048)
%21 = call i32 @memset(i8* %6, i32 0, i32 2048)
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %1)
%23 = call i32 @strlen(i8* %6)
%24 = call i32 @write(i32 %3, i8* %6, i32 %23)
%25 = call i32 @mmsleep(i32 70)
%26 = call i32 @read(i32 %2, i8* %6, i32 2048)
%27 = call i32 @write(i32 %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%28 = call i32 @mmsleep(i32 70)
%29 = call i32 @read(i32 %2, i8* %6, i32 2048)
%30 = call i32 @write(i32 %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%31 = call i32 @mmsleep(i32 70)
%32 = call i32 @read(i32 %2, i8* %6, i32 2048)
ret i32 undef
}