#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 WEXITSTATUS(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
unsigned int strlen(char *);
int /*<<< orphan*/ system(char *);
int handle_connect_specific(char *device, char *id) {
  unsigned int addition = strlen(id) + 16 + strlen(device);
  char cmd[strlen("/etc/samen/") + addition];
  sprintf(cmd, "%sup-%s.sh %s", "/etc/samen/", id, device);
  return WEXITSTATUS(system(cmd));
}


x86 assembly (clang, -O0):
<handle_connect_specific>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x34(%rbp),%ecx
mov    %eax,%edx
mov    %ecx,%eax
mov    %edx,%ecx
lea    0x10(%rax,%rcx,1),%eax
mov    %eax,-0x14(%rbp)
lea    0xe84(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x14(%rbp),%ecx
add    %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%r8
lea    0xe54(%rip),%rsi
lea    0xe41(%rip),%rdx
call   1060 <sprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,%edi
call   1050 <WEXITSTATUS@plt>
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_connect_specific>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
add    %r12d,%ebx
lea    0xe90(%rip),%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
add    %ebx,%eax
add    $0x10,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %eax,%edi
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <WEXITSTATUS@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"/etc/samen/\00"
@.str.1 = [14 x i8] c"%sup-%s.sh %s\00"
define i32 @handle_connect_specific(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = add i32 %9, 16
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = add i32 %10, %12
store i32 %13, i32* %5
%14 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %5
%16 = add i32 %14, %15
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %6
%19 = alloca i8, i64 %17
store i64 %17, i64* %7
%20 = load i8*, i8** %4
%21 = load i8*, i8** %3
%22 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %21)
%23 = call i32 @system(i8* %19)
%24 = call i32 @WEXITSTATUS(i32 %23)
%25 = load i8*, i8** %6
ret i32 %24
}

LLVM IR (-O2):
@.str = [12 x i8] c"/etc/samen/\00"
@.str.1 = [14 x i8] c"%sup-%s.sh %s\00"
define i32 @handle_connect_specific(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = add i32 %3, 16
%5 = tail call i32 @strlen(i8* %0)
%6 = add i32 %4, %5
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = add i32 %6, %7
%9 = zext i32 %8 to i64
%10 = alloca i8, i64 %9
%11 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%12 = call i32 @system(i8* %10)
%13 = tail call i32 @WEXITSTATUS(i32 %12)
ret i32 %13
}