#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 */
typedef int /*<<< orphan*/ directive;

/* Variables and functions */
int /*<<< orphan*/ dodirective(char *, char *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, char *);
int config_parse(char *buffer) {
  char *ptr = NULL;
  char *pos = NULL;
  char *buf = NULL;
  int error_cnt = 0;
  int line_cnt = 0;
  int in_directive = 0;
  int cnt = 0, i = 0, x = 0;
  char directive[250];
  char param[250];
  char value[250];
  while (*buf) {
    switch (*buf) {
    case '\n':
      line_cnt++;
      break;
    case '\t':
      break;
    case '<':
      memset(directive, '\0', sizeof(directive));
      dodirective(buf, directive);
      printf("\n--------\nBuf:\n %s--------\n\n", buf);
      break;
    case '>':
      printf("Directive: %s\n", directive);
      in_directive = 0;
      break;
    case ' ':
      break;
    default:
      *ptr++ = *buf;
      break;
    }
    buf++;
  }
  return line_cnt;
}


x86 assembly (clang, -O0):
<config_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1290 <config_parse+0x160>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x344(%rbp)
sub    $0x9,%eax
je     1207 <config_parse+0xd7>
jmp    11a9 <config_parse+0x79>
mov    -0x344(%rbp),%eax
sub    $0xa,%eax
je     11f9 <config_parse+0xc9>
jmp    11bd <config_parse+0x8d>
mov    -0x344(%rbp),%eax
sub    $0x20,%eax
je     1263 <config_parse+0x133>
jmp    11d1 <config_parse+0xa1>
mov    -0x344(%rbp),%eax
sub    $0x3c,%eax
je     120c <config_parse+0xdc>
jmp    11e5 <config_parse+0xb5>
mov    -0x344(%rbp),%eax
sub    $0x3e,%eax
je     1244 <config_parse+0x114>
jmp    1268 <config_parse+0x138>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    127f <config_parse+0x14f>
jmp    127f <config_parse+0x14f>
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa,%edx
call   1040 <memset@plt>
mov    -0x20(%rbp),%rdi
lea    -0x140(%rbp),%rsi
call   1050 <dodirective@plt>
mov    -0x20(%rbp),%rsi
lea    0xdc6(%rip),%rdi
call   1030 <printf@plt>
jmp    127f <config_parse+0x14f>
lea    -0x140(%rbp),%rsi
lea    0xdcb(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
jmp    127f <config_parse+0x14f>
jmp    127f <config_parse+0x14f>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1181 <config_parse+0x51>
mov    -0x28(%rbp),%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
@.str = [29 x i8] c"\0A--------\0ABuf:\0A %s--------\0A\0A\00"
@.str.1 = [15 x i8] c"Directive: %s\0A\00"
define i32 @config_parse(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [250 x i8]
%13 = alloca [250 x i8]
%14 = alloca [250 x i8]
store i8* %0, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
store i8* null, i8** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %15
15: ; preds = %44, %1
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %47
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
switch i32 %22, label %39 [
i32 10, label %23
i32 9, label %26
i32 60, label %27
i32 62, label %35
i32 32, label %38
]
23: ; preds = %19
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %44
26: ; preds = %19
br label %44
27: ; preds = %19
%28 = getelementptr inbounds [250 x i8], [250 x i8]* %12, i64 0, i64 0
%29 = call i32 @memset(i8* %28, i8 signext 0, i32 250)
%30 = load i8*, i8** %5
%31 = getelementptr inbounds [250 x i8], [250 x i8]* %12, i64 0, i64 0
%32 = call i32 @dodirective(i8* %30, i8* %31)
%33 = load i8*, i8** %5
%34 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %33)
br label %44
35: ; preds = %19
%36 = getelementptr inbounds [250 x i8], [250 x i8]* %12, i64 0, i64 0
%37 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %36)
store i32 0, i32* %8
br label %44
38: ; preds = %19
br label %44
39: ; preds = %19
%40 = load i8*, i8** %5
%41 = load i8, i8* %40
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %3
store i8 %41, i8* %42
br label %44
44: ; preds = %39, %38, %35, %27, %26, %23
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %5
br label %15
47: ; preds = %15
%48 = load i32, i32* %7
ret i32 %48
}

LLVM IR (-O2):