#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*/ printf(char *, char *, char *, int);
int scanf(char *, int *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int num, sum = 0;
  if (argc < 2) {
    return 1;
  }
  while (scanf("%d", &num) == 1) {
    if (strcmp("neg", argv[1]) == 0) {
      if (num < 0) {
        sum += num;
      }
    } else if (strcmp("pos", argv[1]) == 0) {
      if (num > 0) {
        sum += num;
      }
    } else {
      return 1;
    }
  }
  printf("Sum of %s integers in %s is: %d", argv[1], argv[2], sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1163 <main+0x33>
movl   $0x1,-0x4(%rbp)
jmp    1229 <main+0xf9>
jmp    1168 <main+0x38>
lea    0xeb6(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1203 <main+0xd3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe70(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b7 <main+0x87>
cmpl   $0x0,-0x14(%rbp)
jge    11b2 <main+0x82>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11fe <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe3e(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ed <main+0xbd>
cmpl   $0x0,-0x14(%rbp)
jle    11e8 <main+0xb8>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11f9 <main+0xc9>
movl   $0x1,-0x4(%rbp)
jmp    1229 <main+0xf9>
jmp    11fe <main+0xce>
jmp    1168 <main+0x38>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x18(%rbp),%ecx
lea    0xdeb(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    114a <main+0x1a>
mov    $0x1,%eax
jmp    11fb <main+0xcb>
mov    %rsi,%rbx
lea    0xed1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%ebp
cmp    $0x1,%eax
jne    11e3 <main+0xb3>
lea    0xe91(%rip),%r15
lea    0xeaf(%rip),%r12
lea    0x4(%rsp),%r13
lea    0xe82(%rip),%r14
xor    %ebp,%ebp
jmp    11ad <main+0x7d>
cs nopw 0x0(%rax,%rax,1)
mov    0x4(%rsp),%ecx
mov    %ecx,%eax
sar    $0x1f,%eax
and    %ecx,%eax
add    %eax,%ebp
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11e3 <main+0xb3>
mov    0x8(%rbx),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1190 <main+0x60>
mov    0x8(%rbx),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1140 <main+0x10>
mov    0x4(%rsp),%eax
test   %eax,%eax
mov    $0x0,%ecx
cmovs  %ecx,%eax
jmp    119b <main+0x6b>
mov    0x8(%rbx),%rsi
mov    0x10(%rbx),%rdx
lea    0xe16(%rip),%rdi
mov    %ebp,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"neg\00"
@.str.2 = [4 x i8] c"pos\00"
@.str.3 = [32 x i8] c"Sum of %s integers in %s is: %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %3
br label %55
11: ; preds = %2
br label %12
12: ; preds = %45, %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %46
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %15
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = add nsw i32 %26, %25
store i32 %27, i32* %7
br label %28
28: ; preds = %24, %21
br label %45
29: ; preds = %15
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %29
%36 = load i32, i32* %6
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = add nsw i32 %40, %39
store i32 %41, i32* %7
br label %42
42: ; preds = %38, %35
br label %44
43: ; preds = %29
store i32 1, i32* %3
br label %55
44: ; preds = %42
br label %45
45: ; preds = %44, %28
br label %12
46: ; preds = %12
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = load i32, i32* %7
%54 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %49, i8* %52, i32 %53)
store i32 0, i32* %3
br label %55
55: ; preds = %46, %43, %10
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"neg\00"
@.str.2 = [4 x i8] c"pos\00"
@.str.3 = [32 x i8] c"Sum of %s integers in %s is: %d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %40, label %6
6: ; preds = %2
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %33
9: ; preds = %6
%10 = getelementptr inbounds i8*, i8** %1, i64 1
br label %11
11: ; preds = %9, %28
%12 = phi i32 [ 0, %9 ], [ %30, %28 ]
%13 = load i8*, i8** %10
%14 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 0
%19 = select i1 %18, i32 %17, i32 0
br label %28
20: ; preds = %11
%21 = load i8*, i8** %10
%22 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %20
%25 = load i32, i32* %3
%26 = icmp sgt i32 %25, 0
%27 = select i1 %26, i32 %25, i32 0
br label %28
28: ; preds = %24, %16
%29 = phi i32 [ %19, %16 ], [ %27, %24 ]
%30 = add nsw i32 %29, %12
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%32 = icmp eq i32 %31, 1
br i1 %32, label %11, label %33
33: ; preds = %28, %6
%34 = phi i32 [ 0, %6 ], [ %30, %28 ]
%35 = getelementptr inbounds i8*, i8** %1, i64 1
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8*, i8** %1, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %36, i8* %38, i32 %34)
br label %40
40: ; preds = %20, %2, %33
%41 = phi i32 [ 0, %33 ], [ 1, %2 ], [ 1, %20 ]
ret i32 %41
}