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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int);
int /*<<< orphan*/ system(char *);
int adjust_mtu(int mtu) {
  int ret = 0;
  char cmd[256] = {0};
  if (mtu < 596 || mtu > 1500) {
    printf("Error: arg mtu error: %d\n", mtu);
    return -1;
  }
  snprintf(cmd, sizeof(cmd),
           "uci set network.wan.mtu=%d;uci set network.wan.mru=%d;uci commit "
           "network;/etc/init.d/network restart &",
           mtu, mtu);
  printf("exec: %s\n", cmd);
  system(cmd);
  return ret;
}


x86 assembly (clang, -O0):
<adjust_mtu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
cmpl   $0x254,-0x8(%rbp)
jl     1182 <adjust_mtu+0x42>
cmpl   $0x5dc,-0x8(%rbp)
jle    119f <adjust_mtu+0x5f>
mov    -0x8(%rbp),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <adjust_mtu+0xa5>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    $0x100,%esi
lea    0xe61(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x110(%rbp),%rsi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <system@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjust_mtu>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %edi,%ecx
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    -0x5dd(%rcx),%eax
cmp    $0xfffffc76,%eax
ja     11ca <adjust_mtu+0x9a>
lea    0xe46(%rip),%rdi
mov    %ecx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%ebx
jmp    11ff <adjust_mtu+0xcf>
lea    0xe49(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x100,%esi
mov    %ecx,%r8d
call   1050 <snprintf@plt>
lea    0xe96(%rip),%rdi
xor    %ebx,%ebx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <system@plt>
mov    %ebx,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Error: arg mtu error: %d\0A\00"
@.str.1 = [103 x i8] c"uci set network.wan.mtu=%d;uci set network.wan.mru=%d;uci commit network;/etc/init.d/network restart &\00"
@.str.2 = [10 x i8] c"exec: %s\0A\00"
define i32 @adjust_mtu(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [256 x i8]
store i32 %0, i32* %3
store i32 0, i32* %4
%6 = bitcast [256 x i8]* %5 to i8*
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 596
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 1500
br i1 %11, label %12, label %15
12: ; preds = %9, %1
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 -1, i32* %2
br label %25
15: ; preds = %9
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%17 = load i32, i32* %3
%18 = load i32, i32* %3
%19 = call i32 @snprintf(i8* %16, i32 256, i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %18)
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%23 = call i32 @system(i8* %22)
%24 = load i32, i32* %4
store i32 %24, i32* %2
br label %25
25: ; preds = %15, %12
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [26 x i8] c"Error: arg mtu error: %d\0A\00"
@.str.1 = [103 x i8] c"uci set network.wan.mtu=%d;uci set network.wan.mru=%d;uci commit network;/etc/init.d/network restart &\00"
@.str.2 = [10 x i8] c"exec: %s\0A\00"
define i32 @adjust_mtu(i32 %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = add i32 %0, -1501
%5 = icmp ult i32 %4, -905
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %12
8: ; preds = %1
%9 = call i32 @snprintf(i8* %3, i32 256, i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %0)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%11 = call i32 @system(i8* %3)
br label %12
12: ; preds = %8, %6
%13 = phi i32 [ -1, %6 ], [ 0, %8 ]
ret i32 %13
}