#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 addrinfo {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                struct addrinfo **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int strlen(char *);
int system(char *);
int set_timer(char *host, char *user) {
  struct addrinfo *res;
  int ret = getaddrinfo(host, NULL, NULL, &res);
  if (ret) {
    printf("ERROR: resolving host: %s (%i)\n", gai_strerror(ret), ret);
    return ret;
  } else {
    freeaddrinfo(res);
  }
  char *fmt =
      "ssh -y -i /etc/dropbear/dropbear_ecdsa_host_key %s@%s \"DISPLAY=:0 "
      "xdg-open 'https://www.google.com.au/search?q=set+timer+5+min'\"";
  char cmd[strlen(fmt) + strlen(user) + strlen(host)];
  sprintf(cmd, fmt, user, host);
  ret = system(cmd);
  if (ret)
    printf("ERROR: notifying user: %i\n", ret);
  return ret;
}


x86 assembly (clang, -O0):
<set_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x20(%rbp),%rcx
mov    %rdx,%rsi
call   1080 <getaddrinfo@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11c8 <set_timer+0x58>
mov    -0x24(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    %rax,%rsi
mov    -0x24(%rbp),%edx
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1273 <set_timer+0x103>
mov    -0x20(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
lea    0xe48(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
add    %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
call   1070 <sprintf@plt>
mov    -0x48(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1266 <set_timer+0xf6>
mov    -0x24(%rbp),%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_timer>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    -0x30(%rbp),%rcx
xor    %esi,%esi
xor    %edx,%edx
call   1080 <getaddrinfo@plt>
test   %eax,%eax
je     11b3 <set_timer+0x43>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xe5b(%rip),%rdi
mov    %rax,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    122b <set_timer+0xbb>
mov    -0x30(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
lea    0xe5d(%rip),%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%r13d
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
add    %r13d,%ebx
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rsp,%r13
add    %ebx,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1228 <set_timer+0xb8>
lea    0xe82(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rsp
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32 }
@.str = [32 x i8] c"ERROR: resolving host: %s (%i)\0A\00"
@.str.1 = [129 x i8] c"ssh -y -i /etc/dropbear/dropbear_ecdsa_host_key %s@%s \22DISPLAY=:0 xdg-open 'https://www.google.com.au/search?q=set+timer+5+min'\22\00"
@.str.2 = [27 x i8] c"ERROR: notifying user: %i\0A\00"
define i32 @set_timer(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.addrinfo*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = load i8*, i8** %4
%12 = call i32 @getaddrinfo(i8* %11, i32* null, i32* null, %struct.addrinfo** %6)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i32, i32* %7
%17 = call i8* @gai_strerror(i32 %16)
%18 = load i32, i32* %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %18)
%20 = load i32, i32* %7
store i32 %20, i32* %3
br label %49
21: ; preds = %2
%22 = load %struct.addrinfo*, %struct.addrinfo** %6
%23 = call i32 @freeaddrinfo(%struct.addrinfo* %22)
br label %24
24: ; preds = %21
store i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i8** %8
%25 = load i8*, i8** %8
%26 = call i32 @strlen(i8* %25)
%27 = load i8*, i8** %5
%28 = call i32 @strlen(i8* %27)
%29 = add nsw i32 %26, %28
%30 = load i8*, i8** %4
%31 = call i32 @strlen(i8* %30)
%32 = add nsw i32 %29, %31
%33 = zext i32 %32 to i64
%34 = call i8* @llvm.stacksave()
store i8* %34, i8** %9
%35 = alloca i8, i64 %33
store i64 %33, i64* %10
%36 = load i8*, i8** %8
%37 = load i8*, i8** %5
%38 = load i8*, i8** %4
%39 = call i32 @sprintf(i8* %35, i8* %36, i8* %37, i8* %38)
%40 = call i32 @system(i8* %35)
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %24
%44 = load i32, i32* %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %43, %24
%47 = load i32, i32* %7
store i32 %47, i32* %3
%48 = load i8*, i8** %9
br label %49
49: ; preds = %46, %15
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
%struct.addrinfo = type { i32 }
@.str = [32 x i8] c"ERROR: resolving host: %s (%i)\0A\00"
@.str.1 = [129 x i8] c"ssh -y -i /etc/dropbear/dropbear_ecdsa_host_key %s@%s \22DISPLAY=:0 xdg-open 'https://www.google.com.au/search?q=set+timer+5+min'\22\00"
@.str.2 = [27 x i8] c"ERROR: notifying user: %i\0A\00"
define i32 @set_timer(i8* %0, i8* %1) {
%3 = alloca %struct.addrinfo*
%4 = bitcast %struct.addrinfo** %3 to i8*
%5 = call i32 @getaddrinfo(i8* %0, i32* null, i32* null, %struct.addrinfo** %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i8* @gai_strerror(i32 %5)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %5)
br label %27
10: ; preds = %2
%11 = load %struct.addrinfo*, %struct.addrinfo** %3
%12 = call i32 @freeaddrinfo(%struct.addrinfo* %11)
%13 = call i32 @strlen(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @strlen(i8* %1)
%15 = add nsw i32 %14, %13
%16 = call i32 @strlen(i8* %0)
%17 = add nsw i32 %15, %16
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
%20 = alloca i8, i64 %18
%21 = call i32 @sprintf(i8* %20, i8* dereferenceable(1) getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %0)
%22 = call i32 @system(i8* %20)
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %10
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %26
26: ; preds = %24, %10
br label %27
27: ; preds = %26, %7
%28 = phi i32 [ %5, %7 ], [ %22, %26 ]
ret i32 %28
}