#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 /*<<< orphan*/ forkExec(char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char const *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char const *);
void commxForkExec(const char *cmd, char c10, char c01) {
  char c[16];
  char *s;
  strcpy(c, "tty");
  c[3] = c10;
  c[4] = c01;
  c[5] = 0;
  s = malloc(strlen(cmd) + strlen(c) + 1);
  sprintf(s, cmd, c);
  forkExec(s);
}


x86 assembly (clang, -O0):
<commxForkExec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x9(%rbp),%al
mov    %al,-0x1d(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0x1c(%rbp)
movb   $0x0,-0x1b(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1070 <sprintf@plt>
mov    -0x28(%rbp),%rdi
call   1060 <forkExec@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<commxForkExec>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xe97(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %bpl,0x3(%rsp)
mov    %r14b,0x4(%rsp)
movb   $0x0,0x5(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbp
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <forkExec@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"tty\00"
define void @commxForkExec(i8* %0, i8 signext %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca [16 x i8]
%8 = alloca i8*
store i8* %0, i8** %4
store i8 %1, i8* %5
store i8 %2, i8* %6
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = load i8, i8* %5
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 3
store i8 %11, i8* %12
%13 = load i8, i8* %6
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 4
store i8 %13, i8* %14
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 5
store i8 0, i8* %15
%16 = load i8*, i8** %4
%17 = call i64 @strlen(i8* %16)
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%19 = call i64 @strlen(i8* %18)
%20 = add nsw i64 %17, %19
%21 = add nsw i64 %20, 1
%22 = call i8* @malloc(i64 %21)
store i8* %22, i8** %8
%23 = load i8*, i8** %8
%24 = load i8*, i8** %4
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%26 = call i32 @sprintf(i8* %23, i8* %24, i8* %25)
%27 = load i8*, i8** %8
%28 = call i32 @forkExec(i8* %27)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"tty\00"
define void @commxForkExec(i8* nocapture %0, i8 signext %1, i8 signext %2) {
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 3
store i8 %1, i8* %7
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 4
store i8 %2, i8* %8
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 5
store i8 0, i8* %9
%10 = call i64 @strlen(i8* dereferenceable(1) %0)
%11 = call i64 @strlen(i8* %5)
%12 = add i64 %10, 1
%13 = add i64 %12, %11
%14 = call i8* @malloc(i64 %13)
%15 = call i32 @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) %0, i8* %5)
%16 = call i32 @forkExec(i8* %14)
ret void
}