#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 off_t;

/* Variables and functions */
int EXIT_SUCCESS;
int O_CREAT;
int O_EXCL;
int /*<<< orphan*/ O_RDWR;
int O_WRONLY;
int /*<<< orphan*/ SEEK_SET;
int close(int);
int dup(int);
int errno;
int fprintf(int /*<<< orphan*/, char *, ...);
int lseek(int, int, int /*<<< orphan*/);
scalar_t__ memset(void *, int /*<<< orphan*/, size_t);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int read(int, void *, size_t);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int write(int, void const *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int error = 0;
  int arg_i = 0;
  int fprintf_return = 0;
  int read_return = 0;
  int write_return = 0;
  int close_return = 0;
  int file_to_write = 0;
  int file_to_read = 0;
  int char_i = 0;
  char read_buffer[1 + 1] = "";
  off_t lseek_return = 0;
  if (argc < 4) {
    fprintf_return = fprintf(stdout,
                             "Usage: %s <fichier a creer> <mot de "
                             "remplacement> <suite de mots a ecrire> \n",
                             argv[0]);
    if (fprintf_return < 0) {
      perror("Error fprintf");
      return fprintf_return;
    }
    return -1;
  }
  file_to_write = open(argv[1], O_EXCL | O_CREAT | O_WRONLY, 00600);
  if (file_to_write == -1) {
    error = errno;
    perror("Error open");
    return error;
  }
  arg_i = 3;
  while (arg_i < argc) {
    write_return =
        write(file_to_write, (const void *)argv[arg_i], strlen(argv[arg_i]));
    if (write_return == -1) {
      error = errno;
      perror("Error write");
      return error;
    }
    write_return = write(file_to_write, " ", strlen(" "));
    if (write_return == -1) {
      error = errno;
      perror("Error write");
      return error;
    }
    fprintf_return = fprintf(stdout, "%s ", argv[arg_i]);
    if (fprintf_return < 0) {
      perror("Error fprintf");
      return fprintf_return;
    }
    arg_i += 1;
  }
  fprintf(stdout, "\n");
  close_return = close(file_to_write);
  if (close_return == -1) {
    error = errno;
    perror("Error close");
    return error;
  }
  file_to_read = open(argv[1], O_RDWR);
  if (file_to_read == -1) {
    error = errno;
    perror("Error open");
    return error;
  }
  read_buffer[1 + 1] = '\0';
  while ((read_return = read(file_to_read,
                             (void *)memset((void *)read_buffer, 0, (size_t)1),
                             (size_t)1)) != 0) {
    if (read_return == -1) {
      error = errno;
      perror("Error read");
      return error;
    }
    fprintf_return =
        fprintf(stdout, "chaine lue: %s \n", (unsigned char *)read_buffer);
    if (fprintf_return < 0) {
      perror("Error fprintf");
      return fprintf_return;
    }
    for (char_i = 0; char_i < 1; char_i++) {
      if ((unsigned char)read_buffer[char_i] == ' ') {
        file_to_write = dup(file_to_read);
        if (file_to_read == -1) {
          error = errno;
          perror("Error dup");
          return error;
        }
        close_return = close(file_to_read);
        if (close_return == -1) {
          error = errno;
          perror("Error close");
          return error;
        }
        lseek_return = lseek(file_to_write, (off_t)char_i + 1, SEEK_SET);
        if (lseek_return == -1) {
          error = errno;
          perror("Error lseek");
          return error;
        }
        write_return =
            write(file_to_write, (const void *)argv[2], strlen(argv[2]));
        if (write_return == -1) {
          error = errno;
          perror("Error write");
          return error;
        }
        close_return = close(file_to_write);
        if (close_return == -1) {
          error = errno;
          perror("Error close");
          return error;
        }
        return EXIT_SUCCESS;
      }
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
lea    -0x36(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1070 <memset@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1264 <main+0xc4>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdd3(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1258 <main+0xb8>
lea    0xe05(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d5d(%rip),%rax
mov    (%rax),%esi
mov    0x2d7c(%rip),%rax
or     (%rax),%esi
mov    0x2d1b(%rip),%rax
or     (%rax),%esi
mov    $0x180,%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    12c3 <main+0x123>
mov    0x2d21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xda8(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
movl   $0x3,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13e3 <main+0x243>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    133b <main+0x19b>
mov    0x2ca9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xd3b(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x50(%rbp)
lea    0xd2c(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%edi
mov    %eax,%edx
lea    0xd1b(%rip),%rsi
call   1030 <write@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    138e <main+0x1ee>
mov    0x2c56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xce8(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    0x2c23(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xcc8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    13d5 <main+0x235>
lea    0xc88(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12ca <main+0x12a>
mov    0x2bce(%rip),%rax
mov    (%rax),%edi
lea    0xc58(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1432 <main+0x292>
mov    0x2bb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xc54(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2b9f(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    147a <main+0x2da>
mov    0x2b6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xbf1(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
movb   $0x0,-0x34(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x54(%rbp)
lea    -0x36(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1070 <memset@plt>
mov    -0x54(%rbp),%edi
mov    %rax,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     16b4 <main+0x514>
cmpl   $0xffffffff,-0x20(%rbp)
jne    14dd <main+0x33d>
mov    0x2b07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xbb5(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    0x2ad4(%rip),%rax
mov    (%rax),%edi
lea    -0x36(%rbp),%rdx
lea    0xb9c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    151c <main+0x37c>
lea    0xb41(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
movl   $0x0,-0x34(%rbp)
cmpl   $0x1,-0x34(%rbp)
jge    16af <main+0x50f>
movslq -0x34(%rbp),%rax
movzbl -0x36(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    169c <main+0x4fc>
mov    -0x30(%rbp),%edi
call   1050 <dup@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    1577 <main+0x3d7>
mov    0x2a6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xb37(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    -0x30(%rbp),%edi
call   1080 <close@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    15af <main+0x40f>
mov    0x2a35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xad7(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    -0x2c(%rbp),%edi
mov    -0x34(%rbp),%esi
add    $0x1,%esi
mov    0x2a01(%rip),%rax
mov    (%rax),%edx
call   1060 <lseek@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    15f6 <main+0x456>
mov    0x29ee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xac2(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1653 <main+0x4b3>
mov    0x2991(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xa23(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    168b <main+0x4eb>
mov    0x2959(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0x9fb(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
mov    0x291e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    16c0 <main+0x520>
jmp    16a1 <main+0x501>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1523 <main+0x383>
jmp    147e <main+0x2de>
mov    0x28f5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
movw   $0x0,0x6(%rsp)
cmp    $0x3,%edi
jg     11f6 <main+0x56>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe33(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
jns    13d0 <main+0x230>
mov    %eax,%ebx
lea    0xe63(%rip),%rdi
call   10c0 <perror@plt>
mov    %ebx,%ebp
jmp    13d0 <main+0x230>
mov    %edi,%ebp
mov    0x2dd1(%rip),%rax
mov    0x2df2(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x8(%r14),%rdi
mov    0x2d8b(%rip),%rax
or     (%rax),%esi
mov    $0x180,%edx
xor    %eax,%eax
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     13f8 <main+0x258>
mov    %eax,%ebx
mov    %ebp,%r13d
mov    $0x3,%r12d
lea    0xe36(%rip),%r15
xchg   %ax,%ax
mov    (%r14,%r12,8),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     13e1 <main+0x241>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     13e1 <main+0x241>
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
mov    (%r14,%r12,8),%rdx
lea    0xde0(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
test   %eax,%eax
js     1426 <main+0x286>
add    $0x1,%r12
cmp    %r12,%r13
jne    1240 <main+0xa0>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
lea    0xd91(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %ebx,%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
je     140f <main+0x26f>
mov    0x8(%r14),%rdi
mov    0x2d04(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     13f8 <main+0x258>
mov    %eax,%r15d
movb   $0x0,0x8(%rsp)
lea    0x6(%rsp),%rbx
lea    0xd8b(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
mov    $0x1,%edx
mov    %r15d,%edi
mov    %rax,%rsi
call   1090 <read@plt>
test   %eax,%eax
je     13c7 <main+0x227>
cmp    $0xffffffff,%eax
je     1436 <main+0x296>
mov    0x2c71(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
test   %eax,%eax
js     1426 <main+0x286>
cmpb   $0x20,0x6(%rsp)
jne    1310 <main+0x170>
mov    %r15d,%edi
call   1050 <dup@plt>
mov    %eax,%ebx
mov    %r15d,%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
je     140f <main+0x26f>
mov    0x2c39(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    $0x1,%esi
call   1060 <lseek@plt>
cmp    $0xffffffff,%eax
je     144d <main+0x2ad>
mov    0x10(%r14),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     13e1 <main+0x241>
mov    %ebx,%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
je     140f <main+0x26f>
mov    0x2be2(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2be0(%rip),%rax
mov    (%rax),%ebp
lea    0xc75(%rip),%rdi
call   10c0 <perror@plt>
jmp    13d0 <main+0x230>
mov    0x2bc9(%rip),%rax
mov    (%rax),%ebp
lea    0xc53(%rip),%rdi
call   10c0 <perror@plt>
jmp    13d0 <main+0x230>
mov    0x2bb2(%rip),%rax
mov    (%rax),%ebp
lea    0xc57(%rip),%rdi
call   10c0 <perror@plt>
jmp    13d0 <main+0x230>
mov    %eax,%ebp
lea    0xc1e(%rip),%rdi
call   10c0 <perror@plt>
jmp    13d0 <main+0x230>
mov    0x2b8b(%rip),%rax
mov    (%rax),%ebp
lea    0xc3c(%rip),%rdi
call   10c0 <perror@plt>
jmp    13d0 <main+0x230>
mov    0x2b74(%rip),%rax
mov    (%rax),%ebp
lea    0xc41(%rip),%rdi
call   10c0 <perror@plt>
jmp    13d0 <main+0x230>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [77 x i8] c"Usage: %s <fichier a creer> <mot de remplacement> <suite de mots a ecrire> \0A\00"
@.str.1 = [14 x i8] c"Error fprintf\00"
@O_EXCL = global i32 0
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@errno = global i32 0
@.str.2 = [11 x i8] c"Error open\00"
@.str.3 = [12 x i8] c"Error write\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [4 x i8] c"%s \00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [12 x i8] c"Error close\00"
@O_RDWR = global i32 0
@.str.8 = [11 x i8] c"Error read\00"
@.str.9 = [17 x i8] c"chaine lue: %s \0A\00"
@.str.10 = [10 x i8] c"Error dup\00"
@SEEK_SET = global i32 0
@.str.11 = [12 x i8] c"Error lseek\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [2 x i8]
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, 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
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
%17 = bitcast [2 x i8]* %15 to i8*
store i32 0, i32* %16
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %32
20: ; preds = %2
%21 = load i32, i32* @stdout
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %20
%29 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* %8
store i32 %30, i32* %3
br label %222
31: ; preds = %20
store i32 -1, i32* %3
br label %222
32: ; preds = %2
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i32, i32* @O_EXCL
%37 = load i32, i32* @O_CREAT
%38 = or i32 %36, %37
%39 = load i32, i32* @O_WRONLY
%40 = or i32 %38, %39
%41 = call i32 (i8*, i32, ...) @open(i8* %35, i32 %40, i32 384)
store i32 %41, i32* %12
%42 = load i32, i32* %12
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %48
44: ; preds = %32
%45 = load i32, i32* @errno
store i32 %45, i32* %6
%46 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* %6
store i32 %47, i32* %3
br label %222
48: ; preds = %32
store i32 3, i32* %7
br label %49
49: ; preds = %96, %48
%50 = load i32, i32* %7
%51 = load i32, i32* %4
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %99
53: ; preds = %49
%54 = load i32, i32* %12
%55 = load i8**, i8*** %5
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = load i8**, i8*** %5
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = call i32 @strlen(i8* %64)
%66 = call i32 @write(i32 %54, i8* %59, i32 %65)
store i32 %66, i32* %10
%67 = load i32, i32* %10
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %73
69: ; preds = %53
%70 = load i32, i32* @errno
store i32 %70, i32* %6
%71 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%72 = load i32, i32* %6
store i32 %72, i32* %3
br label %222
73: ; preds = %53
%74 = load i32, i32* %12
%75 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%76 = call i32 @write(i32 %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %75)
store i32 %76, i32* %10
%77 = load i32, i32* %10
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %83
79: ; preds = %73
%80 = load i32, i32* @errno
store i32 %80, i32* %6
%81 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%82 = load i32, i32* %6
store i32 %82, i32* %3
br label %222
83: ; preds = %73
%84 = load i32, i32* @stdout
%85 = load i8**, i8*** %5
%86 = load i32, i32* %7
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8*, i8** %85, i64 %87
%89 = load i8*, i8** %88
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %89)
store i32 %90, i32* %8
%91 = load i32, i32* %8
%92 = icmp slt i32 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %83
%94 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%95 = load i32, i32* %8
store i32 %95, i32* %3
br label %222
96: ; preds = %83
%97 = load i32, i32* %7
%98 = add nsw i32 %97, 1
store i32 %98, i32* %7
br label %49
99: ; preds = %49
%100 = load i32, i32* @stdout
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%102 = load i32, i32* %12
%103 = call i32 @close(i32 %102)
store i32 %103, i32* %11
%104 = load i32, i32* %11
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %110
106: ; preds = %99
%107 = load i32, i32* @errno
store i32 %107, i32* %6
%108 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%109 = load i32, i32* %6
store i32 %109, i32* %3
br label %222
110: ; preds = %99
%111 = load i8**, i8*** %5
%112 = getelementptr inbounds i8*, i8** %111, i64 1
%113 = load i8*, i8** %112
%114 = load i32, i32* @O_RDWR
%115 = call i32 (i8*, i32, ...) @open(i8* %113, i32 %114)
store i32 %115, i32* %13
%116 = load i32, i32* %13
%117 = icmp eq i32 %116, -1
br i1 %117, label %118, label %122
118: ; preds = %110
%119 = load i32, i32* @errno
store i32 %119, i32* %6
%120 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%121 = load i32, i32* %6
store i32 %121, i32* %3
br label %222
122: ; preds = %110
%123 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 2
store i8 0, i8* %123
br label %124
124: ; preds = %219, %122
%125 = load i32, i32* %13
%126 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 0
%127 = call i64 @memset(i8* %126, i32 0, i64 1)
%128 = inttoptr i64 %127 to i8*
%129 = call i32 @read(i32 %125, i8* %128, i64 1)
store i32 %129, i32* %9
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %220
131: ; preds = %124
%132 = load i32, i32* %9
%133 = icmp eq i32 %132, -1
br i1 %133, label %134, label %138
134: ; preds = %131
%135 = load i32, i32* @errno
store i32 %135, i32* %6
%136 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%137 = load i32, i32* %6
store i32 %137, i32* %3
br label %222
138: ; preds = %131
%139 = load i32, i32* @stdout
%140 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 0
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %140)
store i32 %141, i32* %8
%142 = load i32, i32* %8
%143 = icmp slt i32 %142, 0
br i1 %143, label %144, label %147
144: ; preds = %138
%145 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%146 = load i32, i32* %8
store i32 %146, i32* %3
br label %222
147: ; preds = %138
store i32 0, i32* %14
br label %148
148: ; preds = %216, %147
%149 = load i32, i32* %14
%150 = icmp slt i32 %149, 1
br i1 %150, label %151, label %219
151: ; preds = %148
%152 = load i32, i32* %14
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 %153
%155 = load i8, i8* %154
%156 = zext i8 %155 to i32
%157 = icmp eq i32 %156, 32
br i1 %157, label %158, label %215
158: ; preds = %151
%159 = load i32, i32* %13
%160 = call i32 @dup(i32 %159)
store i32 %160, i32* %12
%161 = load i32, i32* %13
%162 = icmp eq i32 %161, -1
br i1 %162, label %163, label %167
163: ; preds = %158
%164 = load i32, i32* @errno
store i32 %164, i32* %6
%165 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%166 = load i32, i32* %6
store i32 %166, i32* %3
br label %222
167: ; preds = %158
%168 = load i32, i32* %13
%169 = call i32 @close(i32 %168)
store i32 %169, i32* %11
%170 = load i32, i32* %11
%171 = icmp eq i32 %170, -1
br i1 %171, label %172, label %176
172: ; preds = %167
%173 = load i32, i32* @errno
store i32 %173, i32* %6
%174 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%175 = load i32, i32* %6
store i32 %175, i32* %3
br label %222
176: ; preds = %167
%177 = load i32, i32* %12
%178 = load i32, i32* %14
%179 = add nsw i32 %178, 1
%180 = load i32, i32* @SEEK_SET
%181 = call i32 @lseek(i32 %177, i32 %179, i32 %180)
store i32 %181, i32* %16
%182 = load i32, i32* %16
%183 = icmp eq i32 %182, -1
br i1 %183, label %184, label %188
184: ; preds = %176
%185 = load i32, i32* @errno
store i32 %185, i32* %6
%186 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%187 = load i32, i32* %6
store i32 %187, i32* %3
br label %222
188: ; preds = %176
%189 = load i32, i32* %12
%190 = load i8**, i8*** %5
%191 = getelementptr inbounds i8*, i8** %190, i64 2
%192 = load i8*, i8** %191
%193 = load i8**, i8*** %5
%194 = getelementptr inbounds i8*, i8** %193, i64 2
%195 = load i8*, i8** %194
%196 = call i32 @strlen(i8* %195)
%197 = call i32 @write(i32 %189, i8* %192, i32 %196)
store i32 %197, i32* %10
%198 = load i32, i32* %10
%199 = icmp eq i32 %198, -1
br i1 %199, label %200, label %204
200: ; preds = %188
%201 = load i32, i32* @errno
store i32 %201, i32* %6
%202 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%203 = load i32, i32* %6
store i32 %203, i32* %3
br label %222
204: ; preds = %188
%205 = load i32, i32* %12
%206 = call i32 @close(i32 %205)
store i32 %206, i32* %11
%207 = load i32, i32* %11
%208 = icmp eq i32 %207, -1
br i1 %208, label %209, label %213
209: ; preds = %204
%210 = load i32, i32* @errno
store i32 %210, i32* %6
%211 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%212 = load i32, i32* %6
store i32 %212, i32* %3
br label %222
213: ; preds = %204
%214 = load i32, i32* @EXIT_SUCCESS
store i32 %214, i32* %3
br label %222
215: ; preds = %151
br label %216
216: ; preds = %215
%217 = load i32, i32* %14
%218 = add nsw i32 %217, 1
store i32 %218, i32* %14
br label %148
219: ; preds = %148
br label %124
220: ; preds = %124
%221 = load i32, i32* @EXIT_SUCCESS
store i32 %221, i32* %3
br label %222
222: ; preds = %220, %213, %209, %200, %184, %172, %163, %144, %134, %118, %106, %93, %79, %69, %44, %31, %28
%223 = load i32, i32* %3
ret i32 %223
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [77 x i8] c"Usage: %s <fichier a creer> <mot de remplacement> <suite de mots a ecrire> \0A\00"
@.str.1 = [14 x i8] c"Error fprintf\00"
@O_EXCL = global i32 0
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@errno = global i32 0
@.str.2 = [11 x i8] c"Error open\00"
@.str.3 = [12 x i8] c"Error write\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [4 x i8] c"%s \00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [12 x i8] c"Error close\00"
@O_RDWR = global i32 0
@.str.8 = [11 x i8] c"Error read\00"
@.str.9 = [17 x i8] c"chaine lue: %s \0A\00"
@SEEK_SET = global i32 0
@.str.11 = [12 x i8] c"Error lseek\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i16
%4 = bitcast i16* %3 to i8*
store i16 0, i16* %3
%5 = icmp slt i32 %0, 4
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = load i32, i32* @stdout
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %123
11: ; preds = %6
%12 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %123
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_EXCL
%17 = load i32, i32* @O_CREAT
%18 = or i32 %17, %16
%19 = load i32, i32* @O_WRONLY
%20 = or i32 %18, %19
%21 = tail call i32 (i8*, i32, ...) @open(i8* %15, i32 %20, i32 384)
%22 = icmp eq i32 %21, -1
br i1 %22, label %25, label %23
23: ; preds = %13
%24 = zext i32 %0 to i64
br label %30
25: ; preds = %13
%26 = load i32, i32* @errno
%27 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %123
28: ; preds = %47
%29 = icmp eq i64 %52, %24
br i1 %29, label %55, label %30
30: ; preds = %23, %28
%31 = phi i64 [ 3, %23 ], [ %52, %28 ]
%32 = getelementptr inbounds i8*, i8** %1, i64 %31
%33 = load i8*, i8** %32
%34 = tail call i32 @strlen(i8* %33)
%35 = tail call i32 @write(i32 %21, i8* %33, i32 %34)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = load i32, i32* @errno
%39 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %123
40: ; preds = %30
%41 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%42 = tail call i32 @write(i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32, i32* @errno
%46 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %123
47: ; preds = %40
%48 = load i32, i32* @stdout
%49 = load i8*, i8** %32
%50 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %49)
%51 = icmp slt i32 %50, 0
%52 = add nuw nsw i64 %31, 1
br i1 %51, label %53, label %28
53: ; preds = %47
%54 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %123
55: ; preds = %28
%56 = load i32, i32* @stdout
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%58 = tail call i32 @close(i32 %21)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %63
60: ; preds = %55
%61 = load i32, i32* @errno
%62 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %123
63: ; preds = %55
%64 = load i8*, i8** %14
%65 = load i32, i32* @O_RDWR
%66 = tail call i32 (i8*, i32, ...) @open(i8* %64, i32 %65)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %71
68: ; preds = %63
%69 = load i32, i32* @errno
%70 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %123
71: ; preds = %63
%72 = getelementptr inbounds i16, i16* %3, i64 1
%73 = bitcast i16* %72 to i8*
store i8 0, i8* %73
br label %74
74: ; preds = %87, %71
%75 = call i64 @memset(i8* %4, i32 0, i64 1)
%76 = inttoptr i64 %75 to i8*
%77 = call i32 @read(i32 %66, i8* %76, i64 1)
switch i32 %77, label %81 [
i32 0, label %121
i32 -1, label %78
]
78: ; preds = %74
%79 = load i32, i32* @errno
%80 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
br label %123
81: ; preds = %74
%82 = load i32, i32* @stdout
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i16* %3)
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %81
%86 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %123
87: ; preds = %81
%88 = load i8, i8* %4
%89 = icmp eq i8 %88, 32
br i1 %89, label %90, label %74
90: ; preds = %87
%91 = call i32 @dup(i32 %66)
%92 = call i32 @close(i32 %66)
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %97
94: ; preds = %90
%95 = load i32, i32* @errno
%96 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %123
97: ; preds = %90
%98 = load i32, i32* @SEEK_SET
%99 = call i32 @lseek(i32 %91, i32 1, i32 %98)
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %104
101: ; preds = %97
%102 = load i32, i32* @errno
%103 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
br label %123
104: ; preds = %97
%105 = getelementptr inbounds i8*, i8** %1, i64 2
%106 = load i8*, i8** %105
%107 = call i32 @strlen(i8* %106)
%108 = call i32 @write(i32 %91, i8* %106, i32 %107)
%109 = icmp eq i32 %108, -1
br i1 %109, label %110, label %113
110: ; preds = %104
%111 = load i32, i32* @errno
%112 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %123
113: ; preds = %104
%114 = call i32 @close(i32 %91)
%115 = icmp eq i32 %114, -1
br i1 %115, label %116, label %119
116: ; preds = %113
%117 = load i32, i32* @errno
%118 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %123
119: ; preds = %113
%120 = load i32, i32* @EXIT_SUCCESS
br label %123
121: ; preds = %74
%122 = load i32, i32* @EXIT_SUCCESS
br label %123
123: ; preds = %6, %121, %119, %116, %110, %101, %94, %85, %78, %68, %60, %53, %44, %37, %25, %11
%124 = phi i32 [ %9, %11 ], [ %26, %25 ], [ %38, %37 ], [ %45, %44 ], [ %50, %53 ], [ %61, %60 ], [ %69, %68 ], [ %79, %78 ], [ %83, %85 ], [ %95, %94 ], [ %102, %101 ], [ %111, %110 ], [ %117, %116 ], [ %120, %119 ], [ %122, %121 ], [ -1, %6 ]
ret i32 %124
}