#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*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ strncpy(char *, char *, int);
void upd_child_errmsg(char *parent, char *errmsg) {
  char temp[500], *func = "upd_child_errmsg";
  {};
  {};
  if (errmsg[0] == '\0')
    sprintf(errmsg, "%s:  no Error msg avail!\n", parent);
  else {
    sprintf(temp, "%s: %s", parent, errmsg);
    strncpy(errmsg, temp, 500);
  }
  {};
  {};
}


x86 assembly (clang, -O0):
<upd_child_errmsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec6(%rip),%rax
mov    %rax,-0x218(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116c <upd_child_errmsg+0x4c>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xeb1(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    119e <upd_child_errmsg+0x7e>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xea9(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x210(%rbp),%rsi
mov    $0x1f4,%edx
call   1030 <strncpy@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upd_child_errmsg>:
push   %r14
push   %rbx
sub    $0x1f8,%rsp
mov    %rsi,%rbx
mov    %rdi,%rdx
cmpb   $0x0,(%rsi)
je     1167 <upd_child_errmsg+0x47>
lea    0xede(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1f4,%edx
call   1030 <strncpy@plt>
add    $0x1f8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"upd_child_errmsg\00"
@.str.1 = [26 x i8] c"%s: no Error msg avail!\0A\00"
@.str.2 = [7 x i8] c"%s: %s\00"
define void @upd_child_errmsg(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [500 x i8]
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load i8*, i8** %3
%15 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %24
16: ; preds = %2
%17 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%18 = load i8*, i8** %3
%19 = load i8*, i8** %4
%20 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19)
%21 = load i8*, i8** %4
%22 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%23 = call i32 @strncpy(i8* %21, i8* %22, i32 500)
br label %24
24: ; preds = %16, %12
ret void
}

LLVM IR (-O2):
@.str.1 = [26 x i8] c"%s: no Error msg avail!\0A\00"
@.str.2 = [7 x i8] c"%s: %s\00"
define void @upd_child_errmsg(i8* %0, i8* %1) {
%3 = alloca [500 x i8]
%4 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %1, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %12
9: ; preds = %2
%10 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
%11 = call i32 @strncpy(i8* %1, i8* %4, i32 500)
br label %12
12: ; preds = %9, %7
ret void
}