#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 CheckSet(char *);
int /*<<< orphan*/ SetStrings(char **, char **);
int /*<<< orphan*/ WrMessage(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void WrStringErrors(void) {
  int check;
  char string[20];
  char *null_ptr;
  char *const_ptr;
  SetStrings(&null_ptr, &const_ptr);
  WrMessage("@STRING-ERRORS");
  check = CheckSet("@COPYNULL");
  if (check) {
    WrMessage("@STRING-COPY-NULL");
    strcpy(string, null_ptr);
    printf("Result: %s\n", string);
    WrMessage("@STRING-CONTINUE");
  }
  check = CheckSet("@COPYOVERLAP");
  if (check) {
    WrMessage("@STRING-COPY-OVERLAP");
    strcpy(string, "1234567890");
    strcpy(string, &string[2]);
    printf("Result: %s\n", string);
    WrMessage("@STRING-COPY-OVERLAP-SECOND");
    strcpy(string, "1234567890");
    strcpy(&string[2], string);
    printf("Result: %s\n", string);
    WrMessage("@STRING-CONTINUE");
  }
  check = CheckSet("@CHANGECONST");
  if (check) {
    WrMessage("@STRING-CHANGE-CONSTANT");
    strcpy(const_ptr, "1");
    printf("Result: %s\n", const_ptr);
    WrMessage("@STRING-CONTINUE");
  }
  return;
}


x86 assembly (clang, -O0):
<WrStringErrors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <SetStrings@plt>
lea    0xe94(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe97(%rip),%rdi
call   1040 <CheckSet@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11bf <WrStringErrors+0x6f>
lea    0xe88(%rip),%rdi
call   1070 <WrMessage@plt>
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rsi
lea    0xe7d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe82(%rip),%rdi
call   1040 <CheckSet@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     125e <WrStringErrors+0x10e>
lea    0xe76(%rip),%rdi
call   1070 <WrMessage@plt>
lea    -0x20(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x2,%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rsi
lea    0xe1b(%rip),%rdi
call   1050 <printf@plt>
lea    0xe59(%rip),%rdi
call   1070 <WrMessage@plt>
lea    -0x20(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
add    $0x2,%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rsi
lea    0xdde(%rip),%rdi
call   1050 <printf@plt>
lea    0xdde(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe2c(%rip),%rdi
call   1040 <CheckSet@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     12af <WrStringErrors+0x15f>
lea    0xe20(%rip),%rdi
call   1070 <WrMessage@plt>
mov    -0x30(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rsi
lea    0xd8d(%rip),%rdi
call   1050 <printf@plt>
lea    0xd8d(%rip),%rdi
call   1070 <WrMessage@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WrStringErrors>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <SetStrings@plt>
lea    0xe91(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe94(%rip),%rdi
call   1040 <CheckSet@plt>
test   %eax,%eax
je     11bd <WrStringErrors+0x6d>
lea    0xe8e(%rip),%rdi
call   1070 <WrMessage@plt>
mov    0x8(%rsp),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe82(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
lea    0xe7f(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe84(%rip),%rdi
call   1040 <CheckSet@plt>
test   %eax,%eax
je     124b <WrStringErrors+0xfb>
lea    0xe81(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe8a(%rip),%r14
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0x12(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe24(%rip),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
lea    0xe5c(%rip),%rdi
call   1070 <WrMessage@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
lea    0xdf1(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe3f(%rip),%rdi
call   1040 <CheckSet@plt>
test   %eax,%eax
je     1293 <WrStringErrors+0x143>
lea    0xe3c(%rip),%rdi
call   1070 <WrMessage@plt>
mov    (%rsp),%rdi
lea    0xe44(%rip),%rsi
call   1030 <strcpy@plt>
mov    (%rsp),%rsi
lea    0xda9(%rip),%rdi
call   1050 <printf@plt>
lea    0xda9(%rip),%rdi
call   1070 <WrMessage@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"@STRING-ERRORS\00"
@.str.1 = [10 x i8] c"@COPYNULL\00"
@.str.2 = [18 x i8] c"@STRING-COPY-NULL\00"
@.str.3 = [12 x i8] c"Result: %s\0A\00"
@.str.4 = [17 x i8] c"@STRING-CONTINUE\00"
@.str.5 = [13 x i8] c"@COPYOVERLAP\00"
@.str.6 = [21 x i8] c"@STRING-COPY-OVERLAP\00"
@.str.7 = [11 x i8] c"1234567890\00"
@.str.8 = [28 x i8] c"@STRING-COPY-OVERLAP-SECOND\00"
@.str.9 = [13 x i8] c"@CHANGECONST\00"
@.str.10 = [24 x i8] c"@STRING-CHANGE-CONSTANT\00"
@.str.11 = [2 x i8] c"1\00"
define void @WrStringErrors() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = call i32 @SetStrings(i8** %3, i8** %4)
%6 = call i32 @WrMessage(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @CheckSet(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 %7, i32* %1
%8 = load i32, i32* %1
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %0
%11 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%13 = load i8*, i8** %3
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = call i32 @WrMessage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %10, %0
%19 = call i32 @CheckSet(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
store i32 %19, i32* %1
%20 = load i32, i32* %1
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %40
22: ; preds = %18
%23 = call i32 @WrMessage(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%25 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 2
%28 = call i32 @strcpy(i8* %26, i8* %27)
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%30 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = call i32 @WrMessage(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%33 = call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 2
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%36 = call i32 @strcpy(i8* %34, i8* %35)
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %37)
%39 = call i32 @WrMessage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %22, %18
%41 = call i32 @CheckSet(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
store i32 %41, i32* %1
%42 = load i32, i32* %1
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %40
%45 = call i32 @WrMessage(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
%46 = load i8*, i8** %4
%47 = call i32 @strcpy(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%48 = load i8*, i8** %4
%49 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = call i32 @WrMessage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %51
51: ; preds = %44, %40
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"@STRING-ERRORS\00"
@.str.1 = [10 x i8] c"@COPYNULL\00"
@.str.2 = [18 x i8] c"@STRING-COPY-NULL\00"
@.str.3 = [12 x i8] c"Result: %s\0A\00"
@.str.4 = [17 x i8] c"@STRING-CONTINUE\00"
@.str.5 = [13 x i8] c"@COPYOVERLAP\00"
@.str.6 = [21 x i8] c"@STRING-COPY-OVERLAP\00"
@.str.7 = [11 x i8] c"1234567890\00"
@.str.8 = [28 x i8] c"@STRING-COPY-OVERLAP-SECOND\00"
@.str.9 = [13 x i8] c"@CHANGECONST\00"
@.str.10 = [24 x i8] c"@STRING-CHANGE-CONSTANT\00"
@.str.11 = [2 x i8] c"1\00"
define void @WrStringErrors() {
%1 = alloca [20 x i8]
%2 = alloca i8*
%3 = alloca i8*
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = bitcast i8** %2 to i8*
%6 = bitcast i8** %3 to i8*
%7 = call i32 @SetStrings(i8** %2, i8** %3)
%8 = call i32 @WrMessage(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @CheckSet(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %0
%12 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%13 = load i8*, i8** %2
%14 = call i32 @strcpy(i8* %4, i8* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%16 = call i32 @WrMessage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %17
17: ; preds = %11, %0
%18 = call i32 @CheckSet(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %31, label %20
20: ; preds = %17
%21 = call i32 @WrMessage(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 2
%24 = call i32 @strcpy(i8* %4, i8* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%26 = call i32 @WrMessage(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%27 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%28 = call i32 @strcpy(i8* %23, i8* %4)
%29 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%30 = call i32 @WrMessage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %20, %17
%32 = call i32 @CheckSet(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %41, label %34
34: ; preds = %31
%35 = call i32 @WrMessage(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
%36 = load i8*, i8** %3
%37 = call i32 @strcpy(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%38 = load i8*, i8** %3
%39 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = call i32 @WrMessage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %34, %31
ret void
}