#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*/ barf(char *, void *);
int /*<<< orphan*/ isprint(char);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int /*<<< orphan*/ update_product_description(char *, char *);
int main(int argc, char *argv[], char *envp[]) {
  int i;
  char *id, *desc;
  if (argc < 2)
    barf("Usage: %s <id> <description>\n", argv[0]);
  id = argv[1];
  desc = argv[2];
  if (strlen(id) > 40)
    barf("Fatal: id argument must be less than %u bytes\n", (void *)40);
  for (i = 0; i < strlen(desc) - 1; i++) {
    if (!(isprint(desc[i])))
      barf("Fatal: description argument can only contain printable bytes\n",
           NULL);
  }
  memset(argv[0], 0, strlen(argv[0]));
  for (i = 3; argv[i] != 0; i++)
    memset(argv[i], 0, strlen(argv[i]));
  for (i = 0; envp[i] != 0; i++)
    memset(envp[i], 0, strlen(envp[i]));
  printf("[DEBUG]: desc argument is at %p\n", desc);
  update_product_description(id, desc);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1197 <main+0x37>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe6e(%rip),%rdi
call   1030 <barf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x28,%eax
jle    11d2 <main+0x72>
lea    0xe56(%rip),%rdi
mov    $0x28,%esi
call   1030 <barf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1235 <main+0xd5>
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1080 <isprint@plt>
cmp    $0x0,%eax
jne    1222 <main+0xc2>
lea    0xe34(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <barf@plt>
jmp    1227 <main+0xc7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
movl   $0x3,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     12af <main+0x14f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1260 <main+0x100>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1305 <main+0x1a5>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12b6 <main+0x156>
mov    -0x30(%rbp),%rsi
lea    0xd7b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <update_product_description@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%rbp
cmp    $0x1,%edi
jg     1186 <main+0x26>
mov    0x0(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1030 <barf@plt>
mov    0x8(%rbp),%r14
mov    0x10(%rbp),%r15
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x29,%eax
jl     11ac <main+0x4c>
lea    0xe7c(%rip),%rdi
mov    $0x28,%esi
call   1030 <barf@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1200 <main+0xa0>
xor    %ebx,%ebx
lea    0xe8b(%rip),%r13
jmp    11e6 <main+0x86>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmp    %rax,%rbx
jge    1200 <main+0xa0>
movsbl (%r15,%rbx,1),%edi
call   1080 <isprint@plt>
test   %eax,%eax
jne    11d0 <main+0x70>
mov    %r13,%rdi
xor    %esi,%esi
call   1030 <barf@plt>
jmp    11d0 <main+0x70>
mov    0x0(%rbp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1070 <memset@plt>
mov    0x18(%rbp),%rbx
test   %rbx,%rbx
je     1251 <main+0xf1>
add    $0x20,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1070 <memset@plt>
mov    0x0(%rbp),%rbx
add    $0x8,%rbp
test   %rbx,%rbx
jne    1230 <main+0xd0>
mov    (%r12),%rbx
test   %rbx,%rbx
je     1281 <main+0x121>
add    $0x8,%r12
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1070 <memset@plt>
mov    (%r12),%rbx
add    $0x8,%r12
test   %rbx,%rbx
jne    1260 <main+0x100>
lea    0xe03(%rip),%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <update_product_description@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Usage: %s <id> <description>\0A\00"
@.str.1 = [47 x i8] c"Fatal: id argument must be less than %u bytes\0A\00"
@.str.2 = [62 x i8] c"Fatal: description argument can only contain printable bytes\0A\00"
@.str.3 = [33 x i8] c"[DEBUG]: desc argument is at %p\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i8**, i8*** %6
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @barf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %13, %3
%19 = load i8**, i8*** %6
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %9
%22 = load i8**, i8*** %6
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
store i8* %24, i8** %10
%25 = load i8*, i8** %9
%26 = call i32 @strlen(i8* %25)
%27 = icmp sgt i32 %26, 40
br i1 %27, label %28, label %30
28: ; preds = %18
%29 = call i32 @barf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 40 to i8*))
br label %30
30: ; preds = %28, %18
store i32 0, i32* %8
br label %31
31: ; preds = %48, %30
%32 = load i32, i32* %8
%33 = load i8*, i8** %10
%34 = call i32 @strlen(i8* %33)
%35 = sub nsw i32 %34, 1
%36 = icmp slt i32 %32, %35
br i1 %36, label %37, label %51
37: ; preds = %31
%38 = load i8*, i8** %10
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = call i32 @isprint(i8 signext %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %37
%46 = call i32 @barf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i8* null)
br label %47
47: ; preds = %45, %37
br label %48
48: ; preds = %47
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %31
51: ; preds = %31
%52 = load i8**, i8*** %6
%53 = getelementptr inbounds i8*, i8** %52, i64 0
%54 = load i8*, i8** %53
%55 = load i8**, i8*** %6
%56 = getelementptr inbounds i8*, i8** %55, i64 0
%57 = load i8*, i8** %56
%58 = call i32 @strlen(i8* %57)
%59 = call i32 @memset(i8* %54, i32 0, i32 %58)
store i32 3, i32* %8
br label %60
60: ; preds = %80, %51
%61 = load i8**, i8*** %6
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = icmp ne i8* %65, null
br i1 %66, label %67, label %83
67: ; preds = %60
%68 = load i8**, i8*** %6
%69 = load i32, i32* %8
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
%72 = load i8*, i8** %71
%73 = load i8**, i8*** %6
%74 = load i32, i32* %8
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8*, i8** %73, i64 %75
%77 = load i8*, i8** %76
%78 = call i32 @strlen(i8* %77)
%79 = call i32 @memset(i8* %72, i32 0, i32 %78)
br label %80
80: ; preds = %67
%81 = load i32, i32* %8
%82 = add nsw i32 %81, 1
store i32 %82, i32* %8
br label %60
83: ; preds = %60
store i32 0, i32* %8
br label %84
84: ; preds = %104, %83
%85 = load i8**, i8*** %7
%86 = load i32, i32* %8
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8*, i8** %85, i64 %87
%89 = load i8*, i8** %88
%90 = icmp ne i8* %89, null
br i1 %90, label %91, label %107
91: ; preds = %84
%92 = load i8**, i8*** %7
%93 = load i32, i32* %8
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8*, i8** %92, i64 %94
%96 = load i8*, i8** %95
%97 = load i8**, i8*** %7
%98 = load i32, i32* %8
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8*, i8** %97, i64 %99
%101 = load i8*, i8** %100
%102 = call i32 @strlen(i8* %101)
%103 = call i32 @memset(i8* %96, i32 0, i32 %102)
br label %104
104: ; preds = %91
%105 = load i32, i32* %8
%106 = add nsw i32 %105, 1
store i32 %106, i32* %8
br label %84
107: ; preds = %84
%108 = load i8*, i8** %10
%109 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %108)
%110 = load i8*, i8** %9
%111 = load i8*, i8** %10
%112 = call i32 @update_product_description(i8* %110, i8* %111)
%113 = load i32, i32* %4
ret i32 %113
}

LLVM IR (-O2):
@.str = [30 x i8] c"Usage: %s <id> <description>\0A\00"
@.str.1 = [47 x i8] c"Fatal: id argument must be less than %u bytes\0A\00"
@.str.2 = [62 x i8] c"Fatal: description argument can only contain printable bytes\0A\00"
@.str.3 = [33 x i8] c"[DEBUG]: desc argument is at %p\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture %2) {
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = load i8*, i8** %1
%7 = tail call i32 @barf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %5, %3
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @strlen(i8* %10)
%14 = icmp sgt i32 %13, 40
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = tail call i32 @barf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 40 to i8*))
br label %17
17: ; preds = %15, %8
%18 = tail call i32 @strlen(i8* %12)
%19 = icmp sgt i32 %18, 1
br i1 %19, label %20, label %34
20: ; preds = %17, %28
%21 = phi i64 [ %29, %28 ], [ 0, %17 ]
%22 = getelementptr inbounds i8, i8* %12, i64 %21
%23 = load i8, i8* %22
%24 = tail call i32 @isprint(i8 signext %23)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = tail call i32 @barf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i8* null)
br label %28
28: ; preds = %20, %26
%29 = add nuw nsw i64 %21, 1
%30 = tail call i32 @strlen(i8* %12)
%31 = add nsw i32 %30, -1
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %29, %32
br i1 %33, label %20, label %34
34: ; preds = %28, %17
%35 = load i8*, i8** %1
%36 = tail call i32 @strlen(i8* %35)
%37 = tail call i32 @memset(i8* %35, i32 0, i32 %36)
%38 = getelementptr inbounds i8*, i8** %1, i64 3
%39 = load i8*, i8** %38
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %44, %34
%42 = load i8*, i8** %2
%43 = icmp eq i8* %42, null
br i1 %43, label %62, label %53
44: ; preds = %34, %44
%45 = phi i64 [ %49, %44 ], [ 3, %34 ]
%46 = phi i8* [ %51, %44 ], [ %39, %34 ]
%47 = tail call i32 @strlen(i8* %46)
%48 = tail call i32 @memset(i8* %46, i32 0, i32 %47)
%49 = add nuw i64 %45, 1
%50 = getelementptr inbounds i8*, i8** %1, i64 %49
%51 = load i8*, i8** %50
%52 = icmp eq i8* %51, null
br i1 %52, label %41, label %44
53: ; preds = %41, %53
%54 = phi i64 [ %58, %53 ], [ 0, %41 ]
%55 = phi i8* [ %60, %53 ], [ %42, %41 ]
%56 = tail call i32 @strlen(i8* %55)
%57 = tail call i32 @memset(i8* %55, i32 0, i32 %56)
%58 = add nuw i64 %54, 1
%59 = getelementptr inbounds i8*, i8** %2, i64 %58
%60 = load i8*, i8** %59
%61 = icmp eq i8* %60, null
br i1 %61, label %62, label %53
62: ; preds = %53, %41
%63 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%64 = tail call i32 @update_product_description(i8* %10, i8* %12)
ret i32 0
}