#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 */
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};

/* Variables and functions */
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int const, char *, char const *, char *);
int system(char *);
int update_tunnel_peer_ip(const char *tunnel_dev, struct sockaddr_in *si_peer) {
  const int MAXLEN = 128;
  char update_cmd[MAXLEN];
  snprintf(update_cmd, MAXLEN, "ip tunnel change %s remote %s\n", tunnel_dev,
           inet_ntoa(si_peer->sin_addr));
  return system(update_cmd);
}


x86 assembly (clang, -O0):
<update_tunnel_peer_ip>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x80,-0x14(%rbp)
mov    %rsp,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <inet_ntoa@plt>
mov    -0xa8(%rbp),%rcx
mov    %rax,%r8
lea    -0xa0(%rbp),%rdi
mov    $0x80,%esi
lea    0xe7c(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <system@plt>
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_tunnel_peer_ip>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%rbx
mov    (%rsi),%edi
call   1030 <inet_ntoa@plt>
lea    0xeb5(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x80,%esi
mov    %rbx,%rcx
mov    %rax,%r8
call   1050 <snprintf@plt>
mov    %r14,%rdi
call   1040 <system@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
@.str = [31 x i8] c"ip tunnel change %s remote %s\0A\00"
define i32 @update_tunnel_peer_ip(i8* %0, %struct.sockaddr_in* %1) {
%3 = alloca i8*
%4 = alloca %struct.sockaddr_in*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %4
store i32 128, i32* %5
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %6
%8 = alloca i8, i64 128
%9 = load i8*, i8** %3
%10 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i8* @inet_ntoa(i32 %12)
%14 = call i32 @snprintf(i8* %8, i32 128, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %13)
%15 = call i32 @system(i8* %8)
%16 = load i8*, i8** %6
ret i32 %15
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
@.str = [31 x i8] c"ip tunnel change %s remote %s\0A\00"
define i32 @update_tunnel_peer_ip(i8* %0, %struct.sockaddr_in* nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = tail call i8* @inet_ntoa(i32 %6)
%8 = call i32 @snprintf(i8* %4, i32 128, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %7)
%9 = call i32 @system(i8* %4)
ret i32 %9
}