#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 atoi(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ errorf(char *, int /*<<< orphan*/);
char *strchr(char *, char);
char *strdup(char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int setup_back_fds(char *backend, int f[2]) {
  char *fd1_s, *fd2_s;
  if (!(fd1_s = strdup(backend)))
    errorf("Couldn't dup string: %s\n", strerror(errno));
  if ((fd2_s = strchr(fd1_s, ',')) != 0) {
    *fd2_s = '\0';
    fd2_s++;
  } else {
    fd2_s = fd1_s;
  }
  f[1] = atoi(fd2_s);
  return f[0] = atoi(fd1_s);
}


x86 assembly (clang, -O0):
<setup_back_fds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1193 <setup_back_fds+0x43>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %eax,%esi
lea    0xe72(%rip),%rdi
call   1040 <errorf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11c7 <setup_back_fds+0x77>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11cf <setup_back_fds+0x7f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    -0x10(%rbp),%rcx
mov    %eax,(%rcx)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_back_fds>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1060 <strdup@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <setup_back_fds+0x30>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
call   1040 <errorf@plt>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     119f <setup_back_fds+0x4f>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %eax,0x4(%r14)
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Couldn't dup string: %s\0A\00"
@errno = global i32 0
define i32 @setup_back_fds(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i32* %1, i32** %4
%7 = load i8*, i8** %3
%8 = call i8* @strdup(i8* %7)
store i8* %8, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i32, i32* @errno
%12 = call i32 @strerror(i32 %11)
%13 = call i32 @errorf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %10, %2
%15 = load i8*, i8** %5
%16 = call i8* @strchr(i8* %15, i8 signext 44)
store i8* %16, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i8*, i8** %6
store i8 0, i8* %19
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %6
br label %24
22: ; preds = %14
%23 = load i8*, i8** %5
store i8* %23, i8** %6
br label %24
24: ; preds = %22, %18
%25 = load i8*, i8** %6
%26 = call i32 @atoi(i8* %25)
%27 = load i32*, i32** %4
%28 = getelementptr inbounds i32, i32* %27, i64 1
store i32 %26, i32* %28
%29 = load i8*, i8** %5
%30 = call i32 @atoi(i8* %29)
%31 = load i32*, i32** %4
%32 = getelementptr inbounds i32, i32* %31, i64 0
store i32 %30, i32* %32
ret i32 %30
}

LLVM IR (-O2):
@.str = [25 x i8] c"Couldn't dup string: %s\0A\00"
@errno = global i32 0
define i32 @setup_back_fds(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = tail call i8* @strdup(i8* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @errno
%7 = tail call i32 @strerror(i32 %6)
%8 = tail call i32 @errorf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %5, %2
%10 = tail call i8* @strchr(i8* dereferenceable(1) %3, i8 signext 44)
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %9
store i8 0, i8* %10
%13 = getelementptr inbounds i8, i8* %10, i64 1
br label %14
14: ; preds = %9, %12
%15 = phi i8* [ %13, %12 ], [ %3, %9 ]
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %16, i32* %17
%18 = tail call i32 @atoi(i8* %3)
store i32 %18, i32* %1
ret i32 %18
}